Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You can use each one's session id which is unique to the tab too. Not too sure how to get the current session id but it should be there somewhere (you can see it in <code>Meteor.default_server.sessions</code>, so there is still a way:</p> <p><strong>Client js</strong></p> <pre><code>Meteor.call("test", Meteor.default_connection._lastSessionId, function(err,result) { console.log(result); }); </code></pre> <p><strong>Server side Js</strong></p> <pre><code>Session = { set : function(key, value, sessionid) { console.log(Meteor.default_server.sessions[sessionid]); if(!Meteor.default_server.sessions[sessionid].session_hash) Meteor.default_server.sessions[sessionid].session_hash = {}; Meteor.default_server.sessions[sessionid].session_hash.key = value; }, get : function(key, sessionid) { if(Meteor.default_server.sessions[sessionid].session_hash) return Meteor.default_server.sessions[sessionid].session_hash.key; }, equals: function(key, value, sessionid) { return (this.get(key, sessionid) == value) }, listAllSessionids: function() { return _.pluck(Meteor.default_server.sessions, "id"); } }; Meteor.methods({ test:function(sessionid) { if(!Session.get("initial_load", sessionid)) Session.set("initial_load", new Date().getTime(), sessionid); return Session.get("initial_load", sessionid); } }); </code></pre> <p>I hook into <code>Meteor.default_connection._sessions</code> to store the values so that theres some type of garbage collection involved when the session isn't valid anymore (i.e the user has closed his tabs) to prevent memory being wasted. In <code>livedata_server.js</code> these old sessions get destroyed after 1 minute of no activity on the DDP wire (like the heartbeat).</p> <p>Because the server can see everyone's session you can use the <code>sessionid</code> to access another user's session data. and <code>listAllSessionids</code> to give out an array of all the sessionids currently active.</p> <p><strong>Automatically set session like this.userId in a Method without using a param in a call</strong></p> <p>It looks like there is functionality for this this but its not fully hooked up. The session id would be stored in <code>this.sessionData</code> but its likely still unfinished. Its there to be called in <code>method</code> but theres nowhere that its being set yet (in <code>livedata_connection.js</code> &amp; <code>livedata_server.js</code>)</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload