{"action":"created","issue":{"url":"https://api.github.com/repos/jamesotron/faye-rails/issues/72","labels_url":"https://api.github.com/repos/jamesotron/faye-rails/issues/72/labels{/name}","comments_url":"https://api.github.com/repos/jamesotron/faye-rails/issues/72/comments","events_url":"https://api.github.com/repos/jamesotron/faye-rails/issues/72/events","html_url":"https://github.com/jamesotron/faye-rails/issues/72","id":60299869,"number":72,"title":"User's online status","user":{"login":"przbadu","id":4189129,"avatar_url":"https://avatars.githubusercontent.com/u/4189129?v=3","gravatar_id":"","url":"https://api.github.com/users/przbadu","html_url":"https://github.com/przbadu","followers_url":"https://api.github.com/users/przbadu/followers","following_url":"https://api.github.com/users/przbadu/following{/other_user}","gists_url":"https://api.github.com/users/przbadu/gists{/gist_id}","starred_url":"https://api.github.com/users/przbadu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/przbadu/subscriptions","organizations_url":"https://api.github.com/users/przbadu/orgs","repos_url":"https://api.github.com/users/przbadu/repos","events_url":"https://api.github.com/users/przbadu/events{/privacy}","received_events_url":"https://api.github.com/users/przbadu/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-03-09T05:21:33Z","updated_at":"2015-03-10T21:51:08Z","closed_at":"2015-03-10T21:51:08Z","body":"Hi, I am using ```private_pub``` gem to configure ```faye``` in my applicaiton.\r\n\r\n```ruby\r\n# private_pub.ru\r\n\r\n# Run with: rackup private_pub.ru -s thin -E production\r\nrequire \"bundler/setup\"\r\nrequire \"yaml\"\r\nrequire \"faye\"\r\nrequire \"private_pub\"\r\n\r\n# Only load rails environment if required\r\n# we are calling sidekiq so it is required\r\nrequire ::File.expand_path('../config/environment',  __FILE__)\r\n\r\nFaye::WebSocket.load_adapter('thin')\r\n\r\nPrivatePub.load_config(File.expand_path(\"../config/private_pub.yml\", __FILE__), ENV[\"RAILS_ENV\"] || \"development\")\r\n# run PrivatePub.faye_app\r\n\r\n\r\n\r\n# UPDATED CODE - \r\n# added functionality in gem\r\napp = PrivatePub.faye_app\r\n\r\n# subscribe - online\r\napp.bind(:subscribe) do |client_id, channel|\r\n  puts \"Client subscribe: #{client_id}:#{channel}\"\r\n\r\n  if /\\/user\\/*/.match(channel)\r\n    p \"ok ****8\"\r\n    SubscribeClient.perform_async(client_id, channel)\r\n  end\r\nend\r\n\r\n# unsubscribe - offline\r\napp.bind(:unsubscribe) do |client_id, channel|\r\n  puts \"Client unsubscribe: #{client_id}:#{channel}\"\r\n  UnsubscribeClient.perform_async(client_id)\r\nend\r\n\r\n# disconnect - offline\r\napp.bind(:disconnect) do |client_id|\r\n  puts \"Client disconnect: #{client_id}\"\r\n  UnsubscribeClient.perform_async(client_id)\r\nend\r\n\r\nrun app\r\n```\r\n\r\n\r\nPROBLEM\r\n--------------\r\n\r\nNow, my problem is, when I close browser or browser tab where my app is running, the ```disconnect``` event fires up:\r\n\r\ne.g: \r\n```ruby\r\n    # console log\r\n    Client disconnect: 7q30kyezc4d68kjnyuik9quw42tqk2u\r\n```\r\n\r\n1) But when did ```subscribe``` and ```unsubscribe``` events trigger? ```unsubscribe``` is not triggering when I close browser / tab. Only ```disconnect``` is triggered.\r\n2) Also, when is ```subscribe``` triggered? When I reconnect to application again, it is not triggering.\r\n\r\nWhat I want now is, When user disconnect from the app, I will update that user to offline mode and if he come back to application, I have to update him to online mode again.....How can I acheive this??"},"comment":{"url":"https://api.github.com/repos/jamesotron/faye-rails/issues/comments/78156288","html_url":"https://github.com/jamesotron/faye-rails/issues/72#issuecomment-78156288","issue_url":"https://api.github.com/repos/jamesotron/faye-rails/issues/72","id":78156288,"user":{"login":"jamesotron","id":59449,"avatar_url":"https://avatars.githubusercontent.com/u/59449?v=3","gravatar_id":"","url":"https://api.github.com/users/jamesotron","html_url":"https://github.com/jamesotron","followers_url":"https://api.github.com/users/jamesotron/followers","following_url":"https://api.github.com/users/jamesotron/following{/other_user}","gists_url":"https://api.github.com/users/jamesotron/gists{/gist_id}","starred_url":"https://api.github.com/users/jamesotron/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jamesotron/subscriptions","organizations_url":"https://api.github.com/users/jamesotron/orgs","repos_url":"https://api.github.com/users/jamesotron/repos","events_url":"https://api.github.com/users/jamesotron/events{/privacy}","received_events_url":"https://api.github.com/users/jamesotron/received_events","type":"User","site_admin":false},"created_at":"2015-03-10T21:51:08Z","updated_at":"2015-03-10T21:51:08Z","body":"Hi @przbadu the https://github.com/ryanb/private_pub gem has nothing to do with this project. I suggest you raise this issue over there. Cheers. /cc @ryanb"}}