{"action":"created","issue":{"url":"https://api.github.com/repos/AllJoyn-Cordova/cordova-plugin-alljoyn/issues/44","labels_url":"https://api.github.com/repos/AllJoyn-Cordova/cordova-plugin-alljoyn/issues/44/labels{/name}","comments_url":"https://api.github.com/repos/AllJoyn-Cordova/cordova-plugin-alljoyn/issues/44/comments","events_url":"https://api.github.com/repos/AllJoyn-Cordova/cordova-plugin-alljoyn/issues/44/events","html_url":"https://github.com/AllJoyn-Cordova/cordova-plugin-alljoyn/pull/44","id":70212057,"number":44,"title":"Handling of connection errors / Support reconnect better","user":{"login":"obsoleted","id":666628,"avatar_url":"https://avatars.githubusercontent.com/u/666628?v=3","gravatar_id":"","url":"https://api.github.com/users/obsoleted","html_url":"https://github.com/obsoleted","followers_url":"https://api.github.com/users/obsoleted/followers","following_url":"https://api.github.com/users/obsoleted/following{/other_user}","gists_url":"https://api.github.com/users/obsoleted/gists{/gist_id}","starred_url":"https://api.github.com/users/obsoleted/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/obsoleted/subscriptions","organizations_url":"https://api.github.com/users/obsoleted/orgs","repos_url":"https://api.github.com/users/obsoleted/repos","events_url":"https://api.github.com/users/obsoleted/events{/privacy}","received_events_url":"https://api.github.com/users/obsoleted/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-04-22T19:17:27Z","updated_at":"2015-04-23T06:52:21Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/AllJoyn-Cordova/cordova-plugin-alljoyn/pulls/44","html_url":"https://github.com/AllJoyn-Cordova/cordova-plugin-alljoyn/pull/44","diff_url":"https://github.com/AllJoyn-Cordova/cordova-plugin-alljoyn/pull/44.diff","patch_url":"https://github.com/AllJoyn-Cordova/cordova-plugin-alljoyn/pull/44.patch"},"body":"Starting as a fix for #38  but it may also relate to #39.\r\n\r\nThis PR makes it so the iOS plugin invokes the error callback for the connect exec when a read or write error is encountered during the message loop. It also makes it so that the plugin JS layer resets the connected state when the connect error callback is invoked. Together this allows an app to detect when the connection breaks and attempt to reconnect (by calling AllJoyn.connect again).\r\n\r\nI pushed an update to the TV sample that does this here: https://github.com/obsoleted/cordova-tv-alljoyn/commit/489bffb569d843c87faf0f073dd29a38fa701ba0\r\n\r\n# TODO\r\n- [x] ~~Disconnect and invoke error when failing to send a message also~~ (Not really needed since there will be a failure callback as part of the regular flow. And the message loop will fail and disconnect as well)\r\n- [ ] Check if Windows implementation needs this work and if so do it\r\n- [ ] Check if Android implementation needs this work and if so do it\r\n- [ ] Investigate and add test if possible\r\n- [ ] Return consistent error messages when other apis are called but we are not connected"},"comment":{"url":"https://api.github.com/repos/AllJoyn-Cordova/cordova-plugin-alljoyn/issues/comments/95464636","html_url":"https://github.com/AllJoyn-Cordova/cordova-plugin-alljoyn/pull/44#issuecomment-95464636","issue_url":"https://api.github.com/repos/AllJoyn-Cordova/cordova-plugin-alljoyn/issues/44","id":95464636,"user":{"login":"vjrantal","id":207474,"avatar_url":"https://avatars.githubusercontent.com/u/207474?v=3","gravatar_id":"","url":"https://api.github.com/users/vjrantal","html_url":"https://github.com/vjrantal","followers_url":"https://api.github.com/users/vjrantal/followers","following_url":"https://api.github.com/users/vjrantal/following{/other_user}","gists_url":"https://api.github.com/users/vjrantal/gists{/gist_id}","starred_url":"https://api.github.com/users/vjrantal/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vjrantal/subscriptions","organizations_url":"https://api.github.com/users/vjrantal/orgs","repos_url":"https://api.github.com/users/vjrantal/repos","events_url":"https://api.github.com/users/vjrantal/events{/privacy}","received_events_url":"https://api.github.com/users/vjrantal/received_events","type":"User","site_admin":false},"created_at":"2015-04-23T06:52:21Z","updated_at":"2015-04-23T06:52:21Z","body":"> Are you thinking it would be a specific \"onConnectionLost\" listener\r\n\r\nYes. And to align with existing function names, maybe something like `bus.addConnectionErrorListener`."}}