{"action":"created","comment":{"url":"https://api.github.com/repos/uProxy/uproxy/pulls/comments/86017634","pull_request_review_id":6695458,"id":86017634,"diff_hunk":"@@ -439,12 +436,79 @@ export class CloudSocialProvider {\n       log.warn('cloud contact %1 is not in %2 - cannot remove from storage', host, STORAGE_KEY);\n       return Promise.resolve();\n     }\n+    this.stopMonitoringPresence_(host);\n     // Remove host from savedContacts and clients\n     delete this.savedContacts_[host];\n     delete this.clients_[host];\n     // Update storage with this.savedContacts_\n     return this.saveContacts_();\n   }\n+\n+  private startMonitoringPresence_(host: string) {\n+    if (this.onlinePresenceMonitorIds_[host]) {\n+      log.error('unexpected call to startMonitoringPresence_ for ' + host);\n+      return;\n+    }\n+    // Ping server every minute to see if it is online\n+    const ping = this.ping_.bind(this, host);\n+    const PING_INTERVAL = 60000;\n+    this.onlinePresenceMonitorIds_[host] = setInterval(ping, PING_INTERVAL);\n+    // Ping server immediately (so we don't have to wait 1 min for 1st result).\n+    ping();\n+  }\n+\n+  private stopMonitoringPresence_(host: string) {\n+    if (!this.onlinePresenceMonitorIds_[host]) {\n+      log.error('unexpected call to stopMonitoringPresence_ for ' + host);\n+      return;\n+    }\n+    clearInterval(this.onlinePresenceMonitorIds_[host]);\n+    delete this.onlinePresenceMonitorIds_[host];\n+  }\n+\n+  private ping_(host: string) : Promise<boolean> {\n+    var pinger = new Pinger(host, SSH_SERVER_PORT);\n+    return pinger.pingOnce().then(() => {\n+      return Promise.resolve(true);","path":"src/lib/cloud/social/provider.ts","position":null,"original_position":160,"commit_id":"7993842012eade6f6a1e35685d8c8db56530f27d","original_commit_id":"8508793d86213451605a389c7d9f67416ce7bebc","user":{"login":"dborkan","id":6494307,"avatar_url":"https://avatars.githubusercontent.com/u/6494307?v=3","gravatar_id":"","url":"https://api.github.com/users/dborkan","html_url":"https://github.com/dborkan","followers_url":"https://api.github.com/users/dborkan/followers","following_url":"https://api.github.com/users/dborkan/following{/other_user}","gists_url":"https://api.github.com/users/dborkan/gists{/gist_id}","starred_url":"https://api.github.com/users/dborkan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dborkan/subscriptions","organizations_url":"https://api.github.com/users/dborkan/orgs","repos_url":"https://api.github.com/users/dborkan/repos","events_url":"https://api.github.com/users/dborkan/events{/privacy}","received_events_url":"https://api.github.com/users/dborkan/received_events","type":"User","site_admin":false},"body":"pingOnce() returns a Promise that fulfills if the ping succeeds and rejects if the ping fails.   The purpose of the return true/false is to convert that fulfill/reject into a true/false value so it can be compared to the previous online status.\r\n\r\nI did change the `return Promise.resolve(true)` to just `return true` (and same for false)","created_at":"2016-11-01T20:31:04Z","updated_at":"2016-11-01T21:00:12Z","html_url":"https://github.com/uProxy/uproxy/pull/2798#discussion_r86017634","pull_request_url":"https://api.github.com/repos/uProxy/uproxy/pulls/2798","_links":{"self":{"href":"https://api.github.com/repos/uProxy/uproxy/pulls/comments/86017634"},"html":{"href":"https://github.com/uProxy/uproxy/pull/2798#discussion_r86017634"},"pull_request":{"href":"https://api.github.com/repos/uProxy/uproxy/pulls/2798"}}},"pull_request":{"url":"https://api.github.com/repos/uProxy/uproxy/pulls/2798","id":91699447,"html_url":"https://github.com/uProxy/uproxy/pull/2798","diff_url":"https://github.com/uProxy/uproxy/pull/2798.diff","patch_url":"https://github.com/uProxy/uproxy/pull/2798.patch","issue_url":"https://api.github.com/repos/uProxy/uproxy/issues/2798","number":2798,"state":"open","locked":false,"title":"Check if cloud server is online","user":{"login":"dborkan","id":6494307,"avatar_url":"https://avatars.githubusercontent.com/u/6494307?v=3","gravatar_id":"","url":"https://api.github.com/users/dborkan","html_url":"https://github.com/dborkan","followers_url":"https://api.github.com/users/dborkan/followers","following_url":"https://api.github.com/users/dborkan/following{/other_user}","gists_url":"https://api.github.com/users/dborkan/gists{/gist_id}","starred_url":"https://api.github.com/users/dborkan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dborkan/subscriptions","organizations_url":"https://api.github.com/users/dborkan/orgs","repos_url":"https://api.github.com/users/dborkan/repos","events_url":"https://api.github.com/users/dborkan/events{/privacy}","received_events_url":"https://api.github.com/users/dborkan/received_events","type":"User","site_admin":false},"body":"Check if a cloud server is online.  This is needed now that we will be deploying cloud servers from the uProxy website, invites will be generated ASAP even though the server will not be ready for 2+ minutes.\r\n\r\nWith this change:\r\n* We ping each cloud server once per minute to see if it's online or offline.\r\n* We stop pinging a cloud server if it's removed from the buddylist\r\n* We no longer log out of cloud when the last server (contact) is removed from the buddylist (this was causing error messages to appear because social.logout rejects for Cloud)\r\n* uProxy no longer attempts to send an instance message to Cloud servers (this was resulting in error trace and is not needed by the server)\n\n<!-- Reviewable:start -->\n---\nThis change is [<img src=\"https://reviewable.io/review_button.svg\" height=\"34\" align=\"absmiddle\" alt=\"Reviewable\"/>](https://reviewable.io/reviews/uproxy/uproxy/2798)\n<!-- Reviewable:end -->\n","created_at":"2016-10-31T22:03:28Z","updated_at":"2016-11-01T21:00:41Z","closed_at":null,"merged_at":null,"merge_commit_sha":"1bc44551453165877123c6cabd865d8d53351cc9","assignee":{"login":"trevj","id":5142116,"avatar_url":"https://avatars.githubusercontent.com/u/5142116?v=3","gravatar_id":"","url":"https://api.github.com/users/trevj","html_url":"https://github.com/trevj","followers_url":"https://api.github.com/users/trevj/followers","following_url":"https://api.github.com/users/trevj/following{/other_user}","gists_url":"https://api.github.com/users/trevj/gists{/gist_id}","starred_url":"https://api.github.com/users/trevj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/trevj/subscriptions","organizations_url":"https://api.github.com/users/trevj/orgs","repos_url":"https://api.github.com/users/trevj/repos","events_url":"https://api.github.com/users/trevj/events{/privacy}","received_events_url":"https://api.github.com/users/trevj/received_events","type":"User","site_admin":false},"assignees":[{"login":"trevj","id":5142116,"avatar_url":"https://avatars.githubusercontent.com/u/5142116?v=3","gravatar_id":"","url":"https://api.github.com/users/trevj","html_url":"https://github.com/trevj","followers_url":"https://api.github.com/users/trevj/followers","following_url":"https://api.github.com/users/trevj/following{/other_user}","gists_url":"https://api.github.com/users/trevj/gists{/gist_id}","starred_url":"https://api.github.com/users/trevj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/trevj/subscriptions","organizations_url":"https://api.github.com/users/trevj/orgs","repos_url":"https://api.github.com/users/trevj/repos","events_url":"https://api.github.com/users/trevj/events{/privacy}","received_events_url":"https://api.github.com/users/trevj/received_events","type":"User","site_admin":false}],"milestone":null,"commits_url":"https://api.github.com/repos/uProxy/uproxy/pulls/2798/commits","review_comments_url":"https://api.github.com/repos/uProxy/uproxy/pulls/2798/comments","review_comment_url":"https://api.github.com/repos/uProxy/uproxy/pulls/comments{/number}","comments_url":"https://api.github.com/repos/uProxy/uproxy/issues/2798/comments","statuses_url":"https://api.github.com/repos/uProxy/uproxy/statuses/7993842012eade6f6a1e35685d8c8db56530f27d","head":{"label":"uProxy:dborkan-cloud-ping","ref":"dborkan-cloud-ping","sha":"7993842012eade6f6a1e35685d8c8db56530f27d","user":{"login":"uProxy","id":6548286,"avatar_url":"https://avatars.githubusercontent.com/u/6548286?v=3","gravatar_id":"","url":"https://api.github.com/users/uProxy","html_url":"https://github.com/uProxy","followers_url":"https://api.github.com/users/uProxy/followers","following_url":"https://api.github.com/users/uProxy/following{/other_user}","gists_url":"https://api.github.com/users/uProxy/gists{/gist_id}","starred_url":"https://api.github.com/users/uProxy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/uProxy/subscriptions","organizations_url":"https://api.github.com/users/uProxy/orgs","repos_url":"https://api.github.com/users/uProxy/repos","events_url":"https://api.github.com/users/uProxy/events{/privacy}","received_events_url":"https://api.github.com/users/uProxy/received_events","type":"Organization","site_admin":false},"repo":{"id":18533350,"name":"uproxy","full_name":"uProxy/uproxy","owner":{"login":"uProxy","id":6548286,"avatar_url":"https://avatars.githubusercontent.com/u/6548286?v=3","gravatar_id":"","url":"https://api.github.com/users/uProxy","html_url":"https://github.com/uProxy","followers_url":"https://api.github.com/users/uProxy/followers","following_url":"https://api.github.com/users/uProxy/following{/other_user}","gists_url":"https://api.github.com/users/uProxy/gists{/gist_id}","starred_url":"https://api.github.com/users/uProxy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/uProxy/subscriptions","organizations_url":"https://api.github.com/users/uProxy/orgs","repos_url":"https://api.github.com/users/uProxy/repos","events_url":"https://api.github.com/users/uProxy/events{/privacy}","received_events_url":"https://api.github.com/users/uProxy/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/uProxy/uproxy","description":"Internet without borders","fork":false,"url":"https://api.github.com/repos/uProxy/uproxy","forks_url":"https://api.github.com/repos/uProxy/uproxy/forks","keys_url":"https://api.github.com/repos/uProxy/uproxy/keys{/key_id}","collaborators_url":"https://api.github.com/repos/uProxy/uproxy/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/uProxy/uproxy/teams","hooks_url":"https://api.github.com/repos/uProxy/uproxy/hooks","issue_events_url":"https://api.github.com/repos/uProxy/uproxy/issues/events{/number}","events_url":"https://api.github.com/repos/uProxy/uproxy/events","assignees_url":"https://api.github.com/repos/uProxy/uproxy/assignees{/user}","branches_url":"https://api.github.com/repos/uProxy/uproxy/branches{/branch}","tags_url":"https://api.github.com/repos/uProxy/uproxy/tags","blobs_url":"https://api.github.com/repos/uProxy/uproxy/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/uProxy/uproxy/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/uProxy/uproxy/git/refs{/sha}","trees_url":"https://api.github.com/repos/uProxy/uproxy/git/trees{/sha}","statuses_url":"https://api.github.com/repos/uProxy/uproxy/statuses/{sha}","languages_url":"https://api.github.com/repos/uProxy/uproxy/languages","stargazers_url":"https://api.github.com/repos/uProxy/uproxy/stargazers","contributors_url":"https://api.github.com/repos/uProxy/uproxy/contributors","subscribers_url":"https://api.github.com/repos/uProxy/uproxy/subscribers","subscription_url":"https://api.github.com/repos/uProxy/uproxy/subscription","commits_url":"https://api.github.com/repos/uProxy/uproxy/commits{/sha}","git_commits_url":"https://api.github.com/repos/uProxy/uproxy/git/commits{/sha}","comments_url":"https://api.github.com/repos/uProxy/uproxy/comments{/number}","issue_comment_url":"https://api.github.com/repos/uProxy/uproxy/issues/comments{/number}","contents_url":"https://api.github.com/repos/uProxy/uproxy/contents/{+path}","compare_url":"https://api.github.com/repos/uProxy/uproxy/compare/{base}...{head}","merges_url":"https://api.github.com/repos/uProxy/uproxy/merges","archive_url":"https://api.github.com/repos/uProxy/uproxy/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/uProxy/uproxy/downloads","issues_url":"https://api.github.com/repos/uProxy/uproxy/issues{/number}","pulls_url":"https://api.github.com/repos/uProxy/uproxy/pulls{/number}","milestones_url":"https://api.github.com/repos/uProxy/uproxy/milestones{/number}","notifications_url":"https://api.github.com/repos/uProxy/uproxy/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/uProxy/uproxy/labels{/name}","releases_url":"https://api.github.com/repos/uProxy/uproxy/releases{/id}","deployments_url":"https://api.github.com/repos/uProxy/uproxy/deployments","created_at":"2014-04-07T20:34:40Z","updated_at":"2016-10-30T10:01:25Z","pushed_at":"2016-11-01T21:00:20Z","git_url":"git://github.com/uProxy/uproxy.git","ssh_url":"git@github.com:uProxy/uproxy.git","clone_url":"https://github.com/uProxy/uproxy.git","svn_url":"https://github.com/uProxy/uproxy","homepage":"https://www.uproxy.org/","size":28878,"stargazers_count":454,"watchers_count":454,"language":"TypeScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":110,"mirror_url":null,"open_issues_count":556,"forks":110,"open_issues":556,"watchers":454,"default_branch":"master"}},"base":{"label":"uProxy:master","ref":"master","sha":"0ce08617230c0a92ea8206a57dbdce3ca0457ad6","user":{"login":"uProxy","id":6548286,"avatar_url":"https://avatars.githubusercontent.com/u/6548286?v=3","gravatar_id":"","url":"https://api.github.com/users/uProxy","html_url":"https://github.com/uProxy","followers_url":"https://api.github.com/users/uProxy/followers","following_url":"https://api.github.com/users/uProxy/following{/other_user}","gists_url":"https://api.github.com/users/uProxy/gists{/gist_id}","starred_url":"https://api.github.com/users/uProxy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/uProxy/subscriptions","organizations_url":"https://api.github.com/users/uProxy/orgs","repos_url":"https://api.github.com/users/uProxy/repos","events_url":"https://api.github.com/users/uProxy/events{/privacy}","received_events_url":"https://api.github.com/users/uProxy/received_events","type":"Organization","site_admin":false},"repo":{"id":18533350,"name":"uproxy","full_name":"uProxy/uproxy","owner":{"login":"uProxy","id":6548286,"avatar_url":"https://avatars.githubusercontent.com/u/6548286?v=3","gravatar_id":"","url":"https://api.github.com/users/uProxy","html_url":"https://github.com/uProxy","followers_url":"https://api.github.com/users/uProxy/followers","following_url":"https://api.github.com/users/uProxy/following{/other_user}","gists_url":"https://api.github.com/users/uProxy/gists{/gist_id}","starred_url":"https://api.github.com/users/uProxy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/uProxy/subscriptions","organizations_url":"https://api.github.com/users/uProxy/orgs","repos_url":"https://api.github.com/users/uProxy/repos","events_url":"https://api.github.com/users/uProxy/events{/privacy}","received_events_url":"https://api.github.com/users/uProxy/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/uProxy/uproxy","description":"Internet without borders","fork":false,"url":"https://api.github.com/repos/uProxy/uproxy","forks_url":"https://api.github.com/repos/uProxy/uproxy/forks","keys_url":"https://api.github.com/repos/uProxy/uproxy/keys{/key_id}","collaborators_url":"https://api.github.com/repos/uProxy/uproxy/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/uProxy/uproxy/teams","hooks_url":"https://api.github.com/repos/uProxy/uproxy/hooks","issue_events_url":"https://api.github.com/repos/uProxy/uproxy/issues/events{/number}","events_url":"https://api.github.com/repos/uProxy/uproxy/events","assignees_url":"https://api.github.com/repos/uProxy/uproxy/assignees{/user}","branches_url":"https://api.github.com/repos/uProxy/uproxy/branches{/branch}","tags_url":"https://api.github.com/repos/uProxy/uproxy/tags","blobs_url":"https://api.github.com/repos/uProxy/uproxy/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/uProxy/uproxy/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/uProxy/uproxy/git/refs{/sha}","trees_url":"https://api.github.com/repos/uProxy/uproxy/git/trees{/sha}","statuses_url":"https://api.github.com/repos/uProxy/uproxy/statuses/{sha}","languages_url":"https://api.github.com/repos/uProxy/uproxy/languages","stargazers_url":"https://api.github.com/repos/uProxy/uproxy/stargazers","contributors_url":"https://api.github.com/repos/uProxy/uproxy/contributors","subscribers_url":"https://api.github.com/repos/uProxy/uproxy/subscribers","subscription_url":"https://api.github.com/repos/uProxy/uproxy/subscription","commits_url":"https://api.github.com/repos/uProxy/uproxy/commits{/sha}","git_commits_url":"https://api.github.com/repos/uProxy/uproxy/git/commits{/sha}","comments_url":"https://api.github.com/repos/uProxy/uproxy/comments{/number}","issue_comment_url":"https://api.github.com/repos/uProxy/uproxy/issues/comments{/number}","contents_url":"https://api.github.com/repos/uProxy/uproxy/contents/{+path}","compare_url":"https://api.github.com/repos/uProxy/uproxy/compare/{base}...{head}","merges_url":"https://api.github.com/repos/uProxy/uproxy/merges","archive_url":"https://api.github.com/repos/uProxy/uproxy/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/uProxy/uproxy/downloads","issues_url":"https://api.github.com/repos/uProxy/uproxy/issues{/number}","pulls_url":"https://api.github.com/repos/uProxy/uproxy/pulls{/number}","milestones_url":"https://api.github.com/repos/uProxy/uproxy/milestones{/number}","notifications_url":"https://api.github.com/repos/uProxy/uproxy/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/uProxy/uproxy/labels{/name}","releases_url":"https://api.github.com/repos/uProxy/uproxy/releases{/id}","deployments_url":"https://api.github.com/repos/uProxy/uproxy/deployments","created_at":"2014-04-07T20:34:40Z","updated_at":"2016-10-30T10:01:25Z","pushed_at":"2016-11-01T21:00:20Z","git_url":"git://github.com/uProxy/uproxy.git","ssh_url":"git@github.com:uProxy/uproxy.git","clone_url":"https://github.com/uProxy/uproxy.git","svn_url":"https://github.com/uProxy/uproxy","homepage":"https://www.uproxy.org/","size":28878,"stargazers_count":454,"watchers_count":454,"language":"TypeScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":110,"mirror_url":null,"open_issues_count":556,"forks":110,"open_issues":556,"watchers":454,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/uProxy/uproxy/pulls/2798"},"html":{"href":"https://github.com/uProxy/uproxy/pull/2798"},"issue":{"href":"https://api.github.com/repos/uProxy/uproxy/issues/2798"},"comments":{"href":"https://api.github.com/repos/uProxy/uproxy/issues/2798/comments"},"review_comments":{"href":"https://api.github.com/repos/uProxy/uproxy/pulls/2798/comments"},"review_comment":{"href":"https://api.github.com/repos/uProxy/uproxy/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/uProxy/uproxy/pulls/2798/commits"},"statuses":{"href":"https://api.github.com/repos/uProxy/uproxy/statuses/7993842012eade6f6a1e35685d8c8db56530f27d"}}}}
{"actor":{"display_login":"dborkan"}}