{"action":"created","comment":{"url":"https://api.github.com/repos/mozilla-b2g/gaia/pulls/comments/48912124","id":48912124,"diff_hunk":"@@ -0,0 +1,97 @@\n+var Tcp = require('./tcp');\n+var Response = require('../message').Response;\n+var Command = require('../message').Command;\n+\n+Promises.Socket = Tcp.Socket;\n+\n+var DEFAULT_HOST = 'localhost';\n+var DEFAULT_PORT = 2828;\n+\n+function Promises(options) {\n+  if (!options) {\n+    options = {};\n+  }\n+\n+  this._lastId = 0;\n+  this.host = options.host || DEFAULT_HOST;\n+  this.port = options.port || DEFAULT_PORT;\n+\n+  this.connectionTimeout = options.connectionTimeout || 2000;\n+  this.retryInterval = 300;\n+  this.isSync = true;\n+\n+  this.tcp = new Tcp(options);\n+  this.tcp._handshaking = false;\n+  this.tcp._driver = this;\n+\n+  this.tcp.cbhandshake = function (data){\n+    this._driver.marionetteProtocol = data.marionetteProtocol || 1;\n+    this._driver.traits = data.traits;\n+    this._driver.applicationType = data.applicationType;\n+  }\n+\n+  // receiving command from the server\n+  this.tcp._onClientCommand = function(data) {\n+\n+    if (this._handshaking){\n+      this.cbhandshake(data);\n+      this._handshaking = false;\n+    }\n+\n+    var _response = new Response(0, data);\n+    this._onDeviceResponse({\n+      id: this.connectionId,\n+      response: _response.toMsg()\n+    });\n+  };\n+\n+}\n+\n+Promises.prototype.connect = function(cb) {\n+  var tcp = this.tcp;","path":"tests/jsmarionette/client/marionette-client/lib/marionette/drivers/promises.js","position":51,"original_position":51,"commit_id":"daa8c969ee0d2e1f06f1831e000fc073f884e530","original_commit_id":"daa8c969ee0d2e1f06f1831e000fc073f884e530","user":{"login":"nullaus","id":1350717,"avatar_url":"https://avatars.githubusercontent.com/u/1350717?v=3","gravatar_id":"","url":"https://api.github.com/users/nullaus","html_url":"https://github.com/nullaus","followers_url":"https://api.github.com/users/nullaus/followers","following_url":"https://api.github.com/users/nullaus/following{/other_user}","gists_url":"https://api.github.com/users/nullaus/gists{/gist_id}","starred_url":"https://api.github.com/users/nullaus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nullaus/subscriptions","organizations_url":"https://api.github.com/users/nullaus/orgs","repos_url":"https://api.github.com/users/nullaus/repos","events_url":"https://api.github.com/users/nullaus/events{/privacy}","received_events_url":"https://api.github.com/users/nullaus/received_events","type":"User","site_admin":false},"body":"Shouldn't take a callback anymore.","created_at":"2016-01-05T23:40:57Z","updated_at":"2016-01-05T23:40:57Z","html_url":"https://github.com/mozilla-b2g/gaia/pull/33738#discussion_r48912124","pull_request_url":"https://api.github.com/repos/mozilla-b2g/gaia/pulls/33738","_links":{"self":{"href":"https://api.github.com/repos/mozilla-b2g/gaia/pulls/comments/48912124"},"html":{"href":"https://github.com/mozilla-b2g/gaia/pull/33738#discussion_r48912124"},"pull_request":{"href":"https://api.github.com/repos/mozilla-b2g/gaia/pulls/33738"}}},"pull_request":{"url":"https://api.github.com/repos/mozilla-b2g/gaia/pulls/33738","id":55037172,"html_url":"https://github.com/mozilla-b2g/gaia/pull/33738","diff_url":"https://github.com/mozilla-b2g/gaia/pull/33738.diff","patch_url":"https://github.com/mozilla-b2g/gaia/pull/33738.patch","issue_url":"https://api.github.com/repos/mozilla-b2g/gaia/issues/33738","number":33738,"state":"open","locked":false,"title":"Bug 1227577 - Develop a new marionette-client promises driver r=gaye,aus","user":{"login":"andrenatal","id":973388,"avatar_url":"https://avatars.githubusercontent.com/u/973388?v=3","gravatar_id":"","url":"https://api.github.com/users/andrenatal","html_url":"https://github.com/andrenatal","followers_url":"https://api.github.com/users/andrenatal/followers","following_url":"https://api.github.com/users/andrenatal/following{/other_user}","gists_url":"https://api.github.com/users/andrenatal/gists{/gist_id}","starred_url":"https://api.github.com/users/andrenatal/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andrenatal/subscriptions","organizations_url":"https://api.github.com/users/andrenatal/orgs","repos_url":"https://api.github.com/users/andrenatal/repos","events_url":"https://api.github.com/users/andrenatal/events{/privacy}","received_events_url":"https://api.github.com/users/andrenatal/received_events","type":"User","site_admin":false},"body":"We have two existing marionette client \"drivers\" to handle tcp requests to the marionette server\r\n\r\n    asynchronously with node-style callbacks [1]\r\n    synchronously via sockit-to-me [2]\r\n\r\nWe'd now like to add an additional driver that handles request asynchronicity through promises.\r\n","created_at":"2016-01-04T23:33:00Z","updated_at":"2016-01-05T23:40:57Z","closed_at":null,"merged_at":null,"merge_commit_sha":"66fa9dc346a68f55f33134aac94cdca0ed7aa388","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/mozilla-b2g/gaia/pulls/33738/commits","review_comments_url":"https://api.github.com/repos/mozilla-b2g/gaia/pulls/33738/comments","review_comment_url":"https://api.github.com/repos/mozilla-b2g/gaia/pulls/comments{/number}","comments_url":"https://api.github.com/repos/mozilla-b2g/gaia/issues/33738/comments","statuses_url":"https://api.github.com/repos/mozilla-b2g/gaia/statuses/daa8c969ee0d2e1f06f1831e000fc073f884e530","head":{"label":"andrenatal:_promises_driver_patch","ref":"_promises_driver_patch","sha":"daa8c969ee0d2e1f06f1831e000fc073f884e530","user":{"login":"andrenatal","id":973388,"avatar_url":"https://avatars.githubusercontent.com/u/973388?v=3","gravatar_id":"","url":"https://api.github.com/users/andrenatal","html_url":"https://github.com/andrenatal","followers_url":"https://api.github.com/users/andrenatal/followers","following_url":"https://api.github.com/users/andrenatal/following{/other_user}","gists_url":"https://api.github.com/users/andrenatal/gists{/gist_id}","starred_url":"https://api.github.com/users/andrenatal/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andrenatal/subscriptions","organizations_url":"https://api.github.com/users/andrenatal/orgs","repos_url":"https://api.github.com/users/andrenatal/repos","events_url":"https://api.github.com/users/andrenatal/events{/privacy}","received_events_url":"https://api.github.com/users/andrenatal/received_events","type":"User","site_admin":false},"repo":{"id":37326496,"name":"gaia","full_name":"andrenatal/gaia","owner":{"login":"andrenatal","id":973388,"avatar_url":"https://avatars.githubusercontent.com/u/973388?v=3","gravatar_id":"","url":"https://api.github.com/users/andrenatal","html_url":"https://github.com/andrenatal","followers_url":"https://api.github.com/users/andrenatal/followers","following_url":"https://api.github.com/users/andrenatal/following{/other_user}","gists_url":"https://api.github.com/users/andrenatal/gists{/gist_id}","starred_url":"https://api.github.com/users/andrenatal/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andrenatal/subscriptions","organizations_url":"https://api.github.com/users/andrenatal/orgs","repos_url":"https://api.github.com/users/andrenatal/repos","events_url":"https://api.github.com/users/andrenatal/events{/privacy}","received_events_url":"https://api.github.com/users/andrenatal/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/andrenatal/gaia","description":"Gaia is a HTML5-based Phone UI for the Boot 2 Gecko Project. NOTE: For details of what branches are used for what releases, see","fork":true,"url":"https://api.github.com/repos/andrenatal/gaia","forks_url":"https://api.github.com/repos/andrenatal/gaia/forks","keys_url":"https://api.github.com/repos/andrenatal/gaia/keys{/key_id}","collaborators_url":"https://api.github.com/repos/andrenatal/gaia/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/andrenatal/gaia/teams","hooks_url":"https://api.github.com/repos/andrenatal/gaia/hooks","issue_events_url":"https://api.github.com/repos/andrenatal/gaia/issues/events{/number}","events_url":"https://api.github.com/repos/andrenatal/gaia/events","assignees_url":"https://api.github.com/repos/andrenatal/gaia/assignees{/user}","branches_url":"https://api.github.com/repos/andrenatal/gaia/branches{/branch}","tags_url":"https://api.github.com/repos/andrenatal/gaia/tags","blobs_url":"https://api.github.com/repos/andrenatal/gaia/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/andrenatal/gaia/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/andrenatal/gaia/git/refs{/sha}","trees_url":"https://api.github.com/repos/andrenatal/gaia/git/trees{/sha}","statuses_url":"https://api.github.com/repos/andrenatal/gaia/statuses/{sha}","languages_url":"https://api.github.com/repos/andrenatal/gaia/languages","stargazers_url":"https://api.github.com/repos/andrenatal/gaia/stargazers","contributors_url":"https://api.github.com/repos/andrenatal/gaia/contributors","subscribers_url":"https://api.github.com/repos/andrenatal/gaia/subscribers","subscription_url":"https://api.github.com/repos/andrenatal/gaia/subscription","commits_url":"https://api.github.com/repos/andrenatal/gaia/commits{/sha}","git_commits_url":"https://api.github.com/repos/andrenatal/gaia/git/commits{/sha}","comments_url":"https://api.github.com/repos/andrenatal/gaia/comments{/number}","issue_comment_url":"https://api.github.com/repos/andrenatal/gaia/issues/comments{/number}","contents_url":"https://api.github.com/repos/andrenatal/gaia/contents/{+path}","compare_url":"https://api.github.com/repos/andrenatal/gaia/compare/{base}...{head}","merges_url":"https://api.github.com/repos/andrenatal/gaia/merges","archive_url":"https://api.github.com/repos/andrenatal/gaia/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/andrenatal/gaia/downloads","issues_url":"https://api.github.com/repos/andrenatal/gaia/issues{/number}","pulls_url":"https://api.github.com/repos/andrenatal/gaia/pulls{/number}","milestones_url":"https://api.github.com/repos/andrenatal/gaia/milestones{/number}","notifications_url":"https://api.github.com/repos/andrenatal/gaia/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/andrenatal/gaia/labels{/name}","releases_url":"https://api.github.com/repos/andrenatal/gaia/releases{/id}","created_at":"2015-06-12T14:27:56Z","updated_at":"2015-06-12T14:28:26Z","pushed_at":"2016-01-04T23:31:51Z","git_url":"git://github.com/andrenatal/gaia.git","ssh_url":"git@github.com:andrenatal/gaia.git","clone_url":"https://github.com/andrenatal/gaia.git","svn_url":"https://github.com/andrenatal/gaia","homepage":"https://wiki.mozilla.org/B2G","size":1001430,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"mozilla-b2g:master","ref":"master","sha":"78b2bc4cad3fcf83cbbbe4aeb77079cf956972cf","user":{"login":"mozilla-b2g","id":1261292,"avatar_url":"https://avatars.githubusercontent.com/u/1261292?v=3","gravatar_id":"","url":"https://api.github.com/users/mozilla-b2g","html_url":"https://github.com/mozilla-b2g","followers_url":"https://api.github.com/users/mozilla-b2g/followers","following_url":"https://api.github.com/users/mozilla-b2g/following{/other_user}","gists_url":"https://api.github.com/users/mozilla-b2g/gists{/gist_id}","starred_url":"https://api.github.com/users/mozilla-b2g/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mozilla-b2g/subscriptions","organizations_url":"https://api.github.com/users/mozilla-b2g/orgs","repos_url":"https://api.github.com/users/mozilla-b2g/repos","events_url":"https://api.github.com/users/mozilla-b2g/events{/privacy}","received_events_url":"https://api.github.com/users/mozilla-b2g/received_events","type":"Organization","site_admin":false},"repo":{"id":2317369,"name":"gaia","full_name":"mozilla-b2g/gaia","owner":{"login":"mozilla-b2g","id":1261292,"avatar_url":"https://avatars.githubusercontent.com/u/1261292?v=3","gravatar_id":"","url":"https://api.github.com/users/mozilla-b2g","html_url":"https://github.com/mozilla-b2g","followers_url":"https://api.github.com/users/mozilla-b2g/followers","following_url":"https://api.github.com/users/mozilla-b2g/following{/other_user}","gists_url":"https://api.github.com/users/mozilla-b2g/gists{/gist_id}","starred_url":"https://api.github.com/users/mozilla-b2g/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mozilla-b2g/subscriptions","organizations_url":"https://api.github.com/users/mozilla-b2g/orgs","repos_url":"https://api.github.com/users/mozilla-b2g/repos","events_url":"https://api.github.com/users/mozilla-b2g/events{/privacy}","received_events_url":"https://api.github.com/users/mozilla-b2g/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/mozilla-b2g/gaia","description":"Gaia is a HTML5-based Phone UI for the Boot 2 Gecko Project. NOTE: For details of what branches are used for what releases, see","fork":false,"url":"https://api.github.com/repos/mozilla-b2g/gaia","forks_url":"https://api.github.com/repos/mozilla-b2g/gaia/forks","keys_url":"https://api.github.com/repos/mozilla-b2g/gaia/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mozilla-b2g/gaia/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mozilla-b2g/gaia/teams","hooks_url":"https://api.github.com/repos/mozilla-b2g/gaia/hooks","issue_events_url":"https://api.github.com/repos/mozilla-b2g/gaia/issues/events{/number}","events_url":"https://api.github.com/repos/mozilla-b2g/gaia/events","assignees_url":"https://api.github.com/repos/mozilla-b2g/gaia/assignees{/user}","branches_url":"https://api.github.com/repos/mozilla-b2g/gaia/branches{/branch}","tags_url":"https://api.github.com/repos/mozilla-b2g/gaia/tags","blobs_url":"https://api.github.com/repos/mozilla-b2g/gaia/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mozilla-b2g/gaia/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mozilla-b2g/gaia/git/refs{/sha}","trees_url":"https://api.github.com/repos/mozilla-b2g/gaia/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mozilla-b2g/gaia/statuses/{sha}","languages_url":"https://api.github.com/repos/mozilla-b2g/gaia/languages","stargazers_url":"https://api.github.com/repos/mozilla-b2g/gaia/stargazers","contributors_url":"https://api.github.com/repos/mozilla-b2g/gaia/contributors","subscribers_url":"https://api.github.com/repos/mozilla-b2g/gaia/subscribers","subscription_url":"https://api.github.com/repos/mozilla-b2g/gaia/subscription","commits_url":"https://api.github.com/repos/mozilla-b2g/gaia/commits{/sha}","git_commits_url":"https://api.github.com/repos/mozilla-b2g/gaia/git/commits{/sha}","comments_url":"https://api.github.com/repos/mozilla-b2g/gaia/comments{/number}","issue_comment_url":"https://api.github.com/repos/mozilla-b2g/gaia/issues/comments{/number}","contents_url":"https://api.github.com/repos/mozilla-b2g/gaia/contents/{+path}","compare_url":"https://api.github.com/repos/mozilla-b2g/gaia/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mozilla-b2g/gaia/merges","archive_url":"https://api.github.com/repos/mozilla-b2g/gaia/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mozilla-b2g/gaia/downloads","issues_url":"https://api.github.com/repos/mozilla-b2g/gaia/issues{/number}","pulls_url":"https://api.github.com/repos/mozilla-b2g/gaia/pulls{/number}","milestones_url":"https://api.github.com/repos/mozilla-b2g/gaia/milestones{/number}","notifications_url":"https://api.github.com/repos/mozilla-b2g/gaia/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mozilla-b2g/gaia/labels{/name}","releases_url":"https://api.github.com/repos/mozilla-b2g/gaia/releases{/id}","created_at":"2011-09-03T01:38:46Z","updated_at":"2016-01-04T07:05:21Z","pushed_at":"2016-01-05T23:40:43Z","git_url":"git://github.com/mozilla-b2g/gaia.git","ssh_url":"git@github.com:mozilla-b2g/gaia.git","clone_url":"https://github.com/mozilla-b2g/gaia.git","svn_url":"https://github.com/mozilla-b2g/gaia","homepage":"https://wiki.mozilla.org/B2G","size":1197115,"stargazers_count":2025,"watchers_count":2025,"language":"JavaScript","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":2582,"mirror_url":null,"open_issues_count":1293,"forks":2582,"open_issues":1293,"watchers":2025,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/mozilla-b2g/gaia/pulls/33738"},"html":{"href":"https://github.com/mozilla-b2g/gaia/pull/33738"},"issue":{"href":"https://api.github.com/repos/mozilla-b2g/gaia/issues/33738"},"comments":{"href":"https://api.github.com/repos/mozilla-b2g/gaia/issues/33738/comments"},"review_comments":{"href":"https://api.github.com/repos/mozilla-b2g/gaia/pulls/33738/comments"},"review_comment":{"href":"https://api.github.com/repos/mozilla-b2g/gaia/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/mozilla-b2g/gaia/pulls/33738/commits"},"statuses":{"href":"https://api.github.com/repos/mozilla-b2g/gaia/statuses/daa8c969ee0d2e1f06f1831e000fc073f884e530"}}}}