{"action":"created","issue":{"url":"https://api.github.com/repos/respoke/node-respoke-admin/issues/15","repository_url":"https://api.github.com/repos/respoke/node-respoke-admin","labels_url":"https://api.github.com/repos/respoke/node-respoke-admin/issues/15/labels{/name}","comments_url":"https://api.github.com/repos/respoke/node-respoke-admin/issues/15/comments","events_url":"https://api.github.com/repos/respoke/node-respoke-admin/issues/15/events","html_url":"https://github.com/respoke/node-respoke-admin/pull/15","id":182304804,"number":15,"title":"Feature/autoreconnect with app secret","user":{"login":"ruffrey","id":1668190,"avatar_url":"https://avatars.githubusercontent.com/u/1668190?v=3","gravatar_id":"","url":"https://api.github.com/users/ruffrey","html_url":"https://github.com/ruffrey","followers_url":"https://api.github.com/users/ruffrey/followers","following_url":"https://api.github.com/users/ruffrey/following{/other_user}","gists_url":"https://api.github.com/users/ruffrey/gists{/gist_id}","starred_url":"https://api.github.com/users/ruffrey/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ruffrey/subscriptions","organizations_url":"https://api.github.com/users/ruffrey/orgs","repos_url":"https://api.github.com/users/ruffrey/repos","events_url":"https://api.github.com/users/ruffrey/events{/privacy}","received_events_url":"https://api.github.com/users/ruffrey/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":5,"created_at":"2016-10-11T16:00:10Z","updated_at":"2016-10-11T19:17:44Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/respoke/node-respoke-admin/pulls/15","html_url":"https://github.com/respoke/node-respoke-admin/pull/15","diff_url":"https://github.com/respoke/node-respoke-admin/pull/15.diff","patch_url":"https://github.com/respoke/node-respoke-admin/pull/15.patch"},"body":"After a long-ish period of respoke being unavailable (network issues on client, for example), the socket.io heartbeat/reconnect finally times out and respoke (and/or the client), will tear down the connection's session.\r\n\r\nPreviously the consumer of `respoke-admin` had to implement reconnection logic. This pull request implements opt-in automatic reconnections *when using App-Secret*.\r\n\r\nsample pseudocode reconnection, the old way:\r\n\r\n```js\r\nvar respoke = new Respoke({ 'App-Secret': 'asdf-jkl' });\r\n// ...\r\nvar connectionTimeout; // returned from `setTimeout()`\r\nvar nextConnectionRetry = 1000;\r\nrespoke.auth.connect();\r\nrespoke.once('connect', function () {\r\n  // do stuff now that we are connected\r\n  // join groups, log connected, etc\r\n});\r\nrespoke.on('disconnect', function () {\r\n  // user-implemented reconnection logic\r\n  nextConnectionRetry = nextConnectionRetry * 2;\r\n  connectionTimeout = setTimeout(function () {\r\n    respoke.auth.connect();\r\n  }, nextConnectionRetry);\r\n  var connectionFailure = function (err) {\r\n     console.error('reconnection failure', err);\r\n     nextConnectionRetry = nextConnectionRetry * 2;\r\n     connectionTimeout = setTimeout(function () {\r\n        respoke.auth.connect();\r\n     }, nextConnectionRetry);\r\n  };\r\n  respoke.once('error', connectionFailure);\r\n  respoke.once('connect', function () {\r\n    // ok we connected again\r\n    // join groups, log connected, etc\r\n    clearTimeout(connectionTimeout);\r\n    connectionTimeout = null;\r\n    nextConnectionRetry = 1000;\r\n    respoke.removeEventListener('error', connectionFailure);\r\n  });\r\n});\r\n```\r\n\r\nsample reconnection, the new way:\r\n\r\n```js\r\nvar Respoke = require('respoke-admin');\r\nvar respoke = new Respoke({ 'App-Secret': 'asdf-jkl', autoreconnect: true });\r\nrespoke.auth.connect();\r\nrespoke.on('connect', function () {\r\n   // join groups, log connected, etc\r\n});\r\n```"},"comment":{"url":"https://api.github.com/repos/respoke/node-respoke-admin/issues/comments/253016658","html_url":"https://github.com/respoke/node-respoke-admin/pull/15#issuecomment-253016658","issue_url":"https://api.github.com/repos/respoke/node-respoke-admin/issues/15","id":253016658,"user":{"login":"ruffrey","id":1668190,"avatar_url":"https://avatars.githubusercontent.com/u/1668190?v=3","gravatar_id":"","url":"https://api.github.com/users/ruffrey","html_url":"https://github.com/ruffrey","followers_url":"https://api.github.com/users/ruffrey/followers","following_url":"https://api.github.com/users/ruffrey/following{/other_user}","gists_url":"https://api.github.com/users/ruffrey/gists{/gist_id}","starred_url":"https://api.github.com/users/ruffrey/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ruffrey/subscriptions","organizations_url":"https://api.github.com/users/ruffrey/orgs","repos_url":"https://api.github.com/users/ruffrey/repos","events_url":"https://api.github.com/users/ruffrey/events{/privacy}","received_events_url":"https://api.github.com/users/ruffrey/received_events","type":"User","site_admin":false},"created_at":"2016-10-11T19:17:44Z","updated_at":"2016-10-11T19:17:44Z","body":"https://github.com/nodejs/LTS\r\n![lts timeline](https://github.com/nodejs/LTS/raw/master/schedule.png)\r\n\r\n@leedm777 you weren't kidding about a few weeks. End of October for 0.10. 0.12 only lasts through December."}}
{"actor":{"display_login":"ruffrey"}}