Meteor client disconnected event on server

Simple question, maybe simple answer: how do I know on the server that a certain client has disconnected? Basic use case: the serve would need to know if a player has dropped the connection.


you can do one thing make a event on server and call it from browser with ajax which call after some small time interval settimeinterval using with session values into header and if server din`t get request from user it means he dropped connection

In the publish function, you can watch socket close event as follows.

this.session.socket.on "close", -> # do your thing

 Meteor.publish("yourPublishFunction", function()
            var id = this._session.userId;
            this._session.socket.on("close", Meteor.bindEnvironment(function()
              console.log(id); // called once the user disconnects
            }, function(e){console.log(e)}));

            return YourCollection.find({});

I've created a pretty comprehensive package to keep track of all logged-in sessions from every user, as well as their IP addresses and activity:

To watch for disconnects, you can just do the following, which catches both logouts and browser closes:

UserStatus.on "sessionLogout", (userId, sessionId) ->
  console.log(userId + " with session " + sessionId + " logged out")

You can also check out the code and do something similar for yourself.

Maybe (in the server code)




Need Your Help

error C2664: 'VariantCopy' : cannot convert parameter 2 from 'const VARIANT *' to 'VARIANTARG *'

c++ atl

While using VariantCopy method, I come across the following compile error:

Yet another question regarding the html5 dtd/schema

html5 schema dtd

If there is no DTD or schema to validate the H5 document against, how are we supposed to do document validation? And by document validation, I mean "how are we supposed to ensure our html5 document...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.