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

remove/add class reload's improperly unless position absolute

jquery html css slideshow

I've created a very simple jquery slideshow, however I have an issue when a class is removed from the active image and placed on to the next one.

Netbeans or Eclipse for C++?

c++ eclipse netbeans

I'm currently working on a pet project and need to do C++ development on Windows, Mac, Linux, and Solaris, and I've narrowed it down to Netbeans and Eclipse, so I was wonderig which is more solid a...

Is there any way to prevent m2e from modifying the eclipse .classpath file?

java eclipse maven m2e

I'm converting some of our projects into Maven projects, but m2e changes my .classpath JRE entry from:

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.