{"action":"closed","issue":{"url":"https://api.github.com/repos/nodejs/help/issues/147","repository_url":"https://api.github.com/repos/nodejs/help","labels_url":"https://api.github.com/repos/nodejs/help/issues/147/labels{/name}","comments_url":"https://api.github.com/repos/nodejs/help/issues/147/comments","events_url":"https://api.github.com/repos/nodejs/help/issues/147/events","html_url":"https://github.com/nodejs/help/issues/147","id":149718339,"number":147,"title":"node-user online/offline issue","user":{"login":"erravi62","id":18326766,"avatar_url":"https://avatars.githubusercontent.com/u/18326766?v=3","gravatar_id":"","url":"https://api.github.com/users/erravi62","html_url":"https://github.com/erravi62","followers_url":"https://api.github.com/users/erravi62/followers","following_url":"https://api.github.com/users/erravi62/following{/other_user}","gists_url":"https://api.github.com/users/erravi62/gists{/gist_id}","starred_url":"https://api.github.com/users/erravi62/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/erravi62/subscriptions","organizations_url":"https://api.github.com/users/erravi62/orgs","repos_url":"https://api.github.com/users/erravi62/repos","events_url":"https://api.github.com/users/erravi62/events{/privacy}","received_events_url":"https://api.github.com/users/erravi62/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2016-04-20T09:49:43Z","updated_at":"2016-05-25T05:31:03Z","closed_at":"2016-05-25T05:31:03Z","body":"Hi there,\r\nI'm new to nodejs.I'm trying to integrate real time chat functionality using nodejs,mysql and php.I'm not able to track the bug described as under:\r\nNow what I'm doing that when a new user is connected and logs in to our website,I'm storing the unique USERID in an array, but the moment he leaves the website or close the browser, he is disconnected by splicing out the particular USERID from that array.But the problem arises when the user opens multiple tabs in a browser and closes only single tab, He is displayed as 'offline' which is not true as he is already online.\r\nHere is my code:\r\nio.sockets.on('connection', function(socket){\r\n\tsocket.on('little_newbie', function(userid,username) {\r\n        socket.userid = userid;\r\n        socket.username = username;\r\n\t\t if( clients.indexOf( userid ) === -1 )\r\n\t\t {\r\n\t\t\tclients.push(userid); \r\n\t\t }\r\n\t\tio.sockets.emit('notification', {name:socket.username,message:' is online',socketCount:clients.length});\r\n    });\r\n socket.on('disconnect', function(data) {\r\n\t\tvar index = clients.indexOf( socket.userid );\r\n\t\tif( index !== -1 )\r\n\t\t{\r\n        clients.splice( index, 1 ); \r\n\t\t}\r\n\t\tio.sockets.emit('notification', {name:socket.username,message:' is offline',socketCount:clients.length});\r\n\t\t\r\n    });\r\n});\r\n\r\nIs there any better way? Please suggest!"}}
{"actor":{"display_login":"lordKnighton"}}