'/meta/disconnect' ,'/meta/unsubscribe' channel issue

124 views
Skip to first unread message

John

unread,
Jun 4, 2013, 5:50:36 AM6/4/13
to faye-...@googlegroups.com
Hi all 

  sometimes user disconnect but still it shows , user online , 

 i am using "'/meta/disconnect' ,'/meta/unsubscribe'" , this two values to monitor channel 


Please suggest me 



James Coglan

unread,
Jun 4, 2013, 6:13:21 AM6/4/13
to faye-...@googlegroups.com
On 4 June 2013 11:50, John <mailaga...@gmail.com> wrote:
  sometimes user disconnect but still it shows , user online , 

 i am using "'/meta/disconnect' ,'/meta/unsubscribe'" , this two values to monitor channel 

Sometimes client sessions will end without sending these messages to the server. This usually happens due to network connection problems or browser windows being closed. Because of this, you cannot rely on those messages to detect disconnected clients, and you should use the monitoring API instead:

John

unread,
Jun 5, 2013, 6:10:46 AM6/5/13
to faye-...@googlegroups.com
Hi James

can you please explain a bit , i am using all monitor channel  , but if didn't get request for disconnect/unsubscribe ,then 


please suggest me best way for the same.

James Coglan

unread,
Jun 5, 2013, 6:46:25 AM6/5/13
to faye-...@googlegroups.com
On 5 June 2013 11:10, John <amitdot...@gmail.com> wrote:
can you please explain a bit , i am using all monitor channel  , but if didn't get request for disconnect/unsubscribe ,then 

Instead of monitoring unsubscribe with an extension, e.g.:

server.addExtension({
  incoming: function(message, callback) {
    if (message.channel === '/meta/unsubscribe') {
      // unsubscribe logic
    }
    callback(message);
  }
});

You should listen to the server's unsubscribe event, which will *always* fire when a client session ends even if the client did not disconnect explicitly.

server.bind('unsubscribe', function(clientId) {
  // unsubscribe logic
}); 
Reply all
Reply to author
Forward
0 new messages