{"action":"created","comment":{"url":"https://api.github.com/repos/wolfeman67/node-ari-shared-line-appearances/pulls/comments/28279833","id":28279833,"diff_hunk":"@@ -128,13 +186,58 @@ function updateState(client, name, state) {\n  * @param {Object} inbound- the inbound channel\n  * @param {Object} bridge - Object that defines the bridge to be passed to\n  *   addChannelsToBridge().\n- * @ param {Object} trunkData - the data of the trunk to be used for station\n- *   access.\n+ * @param {Object} extension - the data structure that represents the extension,\n+ *   mainly used for telling whether or not an extension is busy or not\n  * @return {Q} Q promise object.\n  */\n-function originateChannel(client, inbound, bridge, trunkData) {\n-  var defer = Q.defer();\n+function originateInbound(client, inbound, bridge, extension) {\n+\n   var dialed = [];\n+  var defer = Q.defer();\n+\n+  getState(client, bridge.name).then(function(currentState) {\n+\n+    if (currentState !== inUse && currentState !== busy &&\n+        currentState !== ringing) {\n+      extension.getAllStations()\n+        .then(function (stations) {\n+\n+          if (stations.length) {\n+            stations.forEach(function(station) {\n+              dialed.push({endpoint: station, channel: client.Channel()});\n+            });\n+\n+            dialed.forEach(function (object) {\n+              var originate = Q.denodeify(object.channel.originate.bind(\n+                  object.channel));\n+              originate({endpoint: object.endpoint, app: 'sla',\n+                  appArgs: 'dialed', timeout: 10})\n+                .catch(function (err) {\n+                  defer.reject(err);\n+                });\n+\n+              updateState(client, bridge.name, ringing);\n+\n+              object.channel.once('StasisStart', dialedEnteredStasis);\n+              object.channel.once('ChannelDestroyed', dialedChannelHungup);\n+            });\n+           inbound.once('ChannelHangupRequest', inboundHungup);","path":"lib/sla.js","position":247,"original_position":247,"commit_id":"12e1cbd47cc46aa319a0763f417fe8c812fb804c","original_commit_id":"12e1cbd47cc46aa319a0763f417fe8c812fb804c","user":{"login":"wolfeman67","id":10468003,"avatar_url":"https://avatars.githubusercontent.com/u/10468003?v=3","gravatar_id":"","url":"https://api.github.com/users/wolfeman67","html_url":"https://github.com/wolfeman67","followers_url":"https://api.github.com/users/wolfeman67/followers","following_url":"https://api.github.com/users/wolfeman67/following{/other_user}","gists_url":"https://api.github.com/users/wolfeman67/gists{/gist_id}","starred_url":"https://api.github.com/users/wolfeman67/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wolfeman67/subscriptions","organizations_url":"https://api.github.com/users/wolfeman67/orgs","repos_url":"https://api.github.com/users/wolfeman67/repos","events_url":"https://api.github.com/users/wolfeman67/events{/privacy}","received_events_url":"https://api.github.com/users/wolfeman67/received_events","type":"User","site_admin":false},"body":"When an inbound channel hangs up, it goes to the inboundHungup function, and loops through all of the channels in dialed, hanging each up in the process. inboundHungup is an eventListener function that appears after the main body code. Sam said that the acceptable way of writing Javascript code was writing eventListener functions (or other similar functions) after the main code.","created_at":"2015-04-13T21:13:19Z","updated_at":"2015-04-13T21:13:19Z","html_url":"https://github.com/wolfeman67/node-ari-shared-line-appearances/pull/20#discussion_r28279833","pull_request_url":"https://api.github.com/repos/wolfeman67/node-ari-shared-line-appearances/pulls/20","_links":{"self":{"href":"https://api.github.com/repos/wolfeman67/node-ari-shared-line-appearances/pulls/comments/28279833"},"html":{"href":"https://github.com/wolfeman67/node-ari-shared-line-appearances/pull/20#discussion_r28279833"},"pull_request":{"href":"https://api.github.com/repos/wolfeman67/node-ari-shared-line-appearances/pulls/20"}}},"pull_request":{"url":"https://api.github.com/repos/wolfeman67/node-ari-shared-line-appearances/pulls/20","id":32898758,"html_url":"https://github.com/wolfeman67/node-ari-shared-line-appearances/pull/20","diff_url":"https://github.com/wolfeman67/node-ari-shared-line-appearances/pull/20.diff","patch_url":"https://github.com/wolfeman67/node-ari-shared-line-appearances/pull/20.patch","issue_url":"https://api.github.com/repos/wolfeman67/node-ari-shared-line-appearances/issues/20","number":20,"state":"open","locked":false,"title":"Hold basic","user":{"login":"wolfeman67","id":10468003,"avatar_url":"https://avatars.githubusercontent.com/u/10468003?v=3","gravatar_id":"","url":"https://api.github.com/users/wolfeman67","html_url":"https://github.com/wolfeman67","followers_url":"https://api.github.com/users/wolfeman67/followers","following_url":"https://api.github.com/users/wolfeman67/following{/other_user}","gists_url":"https://api.github.com/users/wolfeman67/gists{/gist_id}","starred_url":"https://api.github.com/users/wolfeman67/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wolfeman67/subscriptions","organizations_url":"https://api.github.com/users/wolfeman67/orgs","repos_url":"https://api.github.com/users/wolfeman67/repos","events_url":"https://api.github.com/users/wolfeman67/events{/privacy}","received_events_url":"https://api.github.com/users/wolfeman67/received_events","type":"User","site_admin":false},"body":"Now adds the ability for this application to intercept hold signals from the stations (they have to be in the same Asterisk instance).  If all stations in the shared extension have either pressed the hold button or hung up, music on hold will be played on the outside user's device.  If a station dials in again while music on hold is being played, then the outside user will be put off hold, music on hold will cease, and conversations between station/s and an outside user continue as normal.  The only for an extension to be freed is if the outside user hangs up.","created_at":"2015-04-08T20:29:58Z","updated_at":"2015-04-13T21:13:19Z","closed_at":null,"merged_at":null,"merge_commit_sha":"9a2166cb07903f62d197a7074dadf295b9b8e249","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/wolfeman67/node-ari-shared-line-appearances/pulls/20/commits","review_comments_url":"https://api.github.com/repos/wolfeman67/node-ari-shared-line-appearances/pulls/20/comments","review_comment_url":"https://api.github.com/repos/wolfeman67/node-ari-shared-line-appearances/pulls/comments{/number}","comments_url":"https://api.github.com/repos/wolfeman67/node-ari-shared-line-appearances/issues/20/comments","statuses_url":"https://api.github.com/repos/wolfeman67/node-ari-shared-line-appearances/statuses/12e1cbd47cc46aa319a0763f417fe8c812fb804c","head":{"label":"wolfeman67:holdBasic","ref":"holdBasic","sha":"12e1cbd47cc46aa319a0763f417fe8c812fb804c","user":{"login":"wolfeman67","id":10468003,"avatar_url":"https://avatars.githubusercontent.com/u/10468003?v=3","gravatar_id":"","url":"https://api.github.com/users/wolfeman67","html_url":"https://github.com/wolfeman67","followers_url":"https://api.github.com/users/wolfeman67/followers","following_url":"https://api.github.com/users/wolfeman67/following{/other_user}","gists_url":"https://api.github.com/users/wolfeman67/gists{/gist_id}","starred_url":"https://api.github.com/users/wolfeman67/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wolfeman67/subscriptions","organizations_url":"https://api.github.com/users/wolfeman67/orgs","repos_url":"https://api.github.com/users/wolfeman67/repos","events_url":"https://api.github.com/users/wolfeman67/events{/privacy}","received_events_url":"https://api.github.com/users/wolfeman67/received_events","type":"User","site_admin":false},"repo":{"id":30209409,"name":"node-ari-shared-line-appearances","full_name":"wolfeman67/node-ari-shared-line-appearances","owner":{"login":"wolfeman67","id":10468003,"avatar_url":"https://avatars.githubusercontent.com/u/10468003?v=3","gravatar_id":"","url":"https://api.github.com/users/wolfeman67","html_url":"https://github.com/wolfeman67","followers_url":"https://api.github.com/users/wolfeman67/followers","following_url":"https://api.github.com/users/wolfeman67/following{/other_user}","gists_url":"https://api.github.com/users/wolfeman67/gists{/gist_id}","starred_url":"https://api.github.com/users/wolfeman67/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wolfeman67/subscriptions","organizations_url":"https://api.github.com/users/wolfeman67/orgs","repos_url":"https://api.github.com/users/wolfeman67/repos","events_url":"https://api.github.com/users/wolfeman67/events{/privacy}","received_events_url":"https://api.github.com/users/wolfeman67/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/wolfeman67/node-ari-shared-line-appearances","description":"Co-op implementation of SLA in ARI using Node.js","fork":false,"url":"https://api.github.com/repos/wolfeman67/node-ari-shared-line-appearances","forks_url":"https://api.github.com/repos/wolfeman67/node-ari-shared-line-appearances/forks","keys_url":"https://api.github.com/repos/wolfeman67/node-ari-shared-line-appearances/keys{/key_id}","collaborators_url":"https://api.github.com/repos/wolfeman67/node-ari-shared-line-appearances/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/wolfeman67/node-ari-shared-line-appearances/teams","hooks_url":"https://api.github.com/repos/wolfeman67/node-ari-shared-line-appearances/hooks","issue_events_url":"https://api.github.com/repos/wolfeman67/node-ari-shared-line-appearances/issues/events{/number}","events_url":"https://api.github.com/repos/wolfeman67/node-ari-shared-line-appearances/events","assignees_url":"https://api.github.com/repos/wolfeman67/node-ari-shared-line-appearances/assignees{/user}","branches_url":"https://api.github.com/repos/wolfeman67/node-ari-shared-line-appearances/branches{/branch}","tags_url":"https://api.github.com/repos/wolfeman67/node-ari-shared-line-appearances/tags","blobs_url":"https://api.github.com/repos/wolfeman67/node-ari-shared-line-appearances/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/wolfeman67/node-ari-shared-line-appearances/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/wolfeman67/node-ari-shared-line-appearances/git/refs{/sha}","trees_url":"https://api.github.com/repos/wolfeman67/node-ari-shared-line-appearances/git/trees{/sha}","statuses_url":"https://api.github.com/repos/wolfeman67/node-ari-shared-line-appearances/statuses/{sha}","languages_url":"https://api.github.com/repos/wolfeman67/node-ari-shared-line-appearances/languages","stargazers_url":"https://api.github.com/repos/wolfeman67/node-ari-shared-line-appearances/stargazers","contributors_url":"https://api.github.com/repos/wolfeman67/node-ari-shared-line-appearances/contributors","subscribers_url":"https://api.github.com/repos/wolfeman67/node-ari-shared-line-appearances/subscribers","subscription_url":"https://api.github.com/repos/wolfeman67/node-ari-shared-line-appearances/subscription","commits_url":"https://api.github.com/repos/wolfeman67/node-ari-shared-line-appearances/commits{/sha}","git_commits_url":"https://api.github.com/repos/wolfeman67/node-ari-shared-line-appearances/git/commits{/sha}","comments_url":"https://api.github.com/repos/wolfeman67/node-ari-shared-line-appearances/comments{/number}","issue_comment_url":"https://api.github.com/repos/wolfeman67/node-ari-shared-line-appearances/issues/comments{/number}","contents_url":"https://api.github.com/repos/wolfeman67/node-ari-shared-line-appearances/contents/{+path}","compare_url":"https://api.github.com/repos/wolfeman67/node-ari-shared-line-appearances/compare/{base}...{head}","merges_url":"https://api.github.com/repos/wolfeman67/node-ari-shared-line-appearances/merges","archive_url":"https://api.github.com/repos/wolfeman67/node-ari-shared-line-appearances/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/wolfeman67/node-ari-shared-line-appearances/downloads","issues_url":"https://api.github.com/repos/wolfeman67/node-ari-shared-line-appearances/issues{/number}","pulls_url":"https://api.github.com/repos/wolfeman67/node-ari-shared-line-appearances/pulls{/number}","milestones_url":"https://api.github.com/repos/wolfeman67/node-ari-shared-line-appearances/milestones{/number}","notifications_url":"https://api.github.com/repos/wolfeman67/node-ari-shared-line-appearances/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/wolfeman67/node-ari-shared-line-appearances/labels{/name}","releases_url":"https://api.github.com/repos/wolfeman67/node-ari-shared-line-appearances/releases{/id}","created_at":"2015-02-02T21:23:52Z","updated_at":"2015-04-03T19:20:45Z","pushed_at":"2015-04-09T21:58:54Z","git_url":"git://github.com/wolfeman67/node-ari-shared-line-appearances.git","ssh_url":"git@github.com:wolfeman67/node-ari-shared-line-appearances.git","clone_url":"https://github.com/wolfeman67/node-ari-shared-line-appearances.git","svn_url":"https://github.com/wolfeman67/node-ari-shared-line-appearances","homepage":null,"size":861,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":2,"forks":1,"open_issues":2,"watchers":0,"default_branch":"master"}},"base":{"label":"wolfeman67:master","ref":"master","sha":"66cf578737241339a24026866ecb3a2273df12b7","user":{"login":"wolfeman67","id":10468003,"avatar_url":"https://avatars.githubusercontent.com/u/10468003?v=3","gravatar_id":"","url":"https://api.github.com/users/wolfeman67","html_url":"https://github.com/wolfeman67","followers_url":"https://api.github.com/users/wolfeman67/followers","following_url":"https://api.github.com/users/wolfeman67/following{/other_user}","gists_url":"https://api.github.com/users/wolfeman67/gists{/gist_id}","starred_url":"https://api.github.com/users/wolfeman67/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wolfeman67/subscriptions","organizations_url":"https://api.github.com/users/wolfeman67/orgs","repos_url":"https://api.github.com/users/wolfeman67/repos","events_url":"https://api.github.com/users/wolfeman67/events{/privacy}","received_events_url":"https://api.github.com/users/wolfeman67/received_events","type":"User","site_admin":false},"repo":{"id":30209409,"name":"node-ari-shared-line-appearances","full_name":"wolfeman67/node-ari-shared-line-appearances","owner":{"login":"wolfeman67","id":10468003,"avatar_url":"https://avatars.githubusercontent.com/u/10468003?v=3","gravatar_id":"","url":"https://api.github.com/users/wolfeman67","html_url":"https://github.com/wolfeman67","followers_url":"https://api.github.com/users/wolfeman67/followers","following_url":"https://api.github.com/users/wolfeman67/following{/other_user}","gists_url":"https://api.github.com/users/wolfeman67/gists{/gist_id}","starred_url":"https://api.github.com/users/wolfeman67/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wolfeman67/subscriptions","organizations_url":"https://api.github.com/users/wolfeman67/orgs","repos_url":"https://api.github.com/users/wolfeman67/repos","events_url":"https://api.github.com/users/wolfeman67/events{/privacy}","received_events_url":"https://api.github.com/users/wolfeman67/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/wolfeman67/node-ari-shared-line-appearances","description":"Co-op implementation of SLA in ARI using Node.js","fork":false,"url":"https://api.github.com/repos/wolfeman67/node-ari-shared-line-appearances","forks_url":"https://api.github.com/repos/wolfeman67/node-ari-shared-line-appearances/forks","keys_url":"https://api.github.com/repos/wolfeman67/node-ari-shared-line-appearances/keys{/key_id}","collaborators_url":"https://api.github.com/repos/wolfeman67/node-ari-shared-line-appearances/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/wolfeman67/node-ari-shared-line-appearances/teams","hooks_url":"https://api.github.com/repos/wolfeman67/node-ari-shared-line-appearances/hooks","issue_events_url":"https://api.github.com/repos/wolfeman67/node-ari-shared-line-appearances/issues/events{/number}","events_url":"https://api.github.com/repos/wolfeman67/node-ari-shared-line-appearances/events","assignees_url":"https://api.github.com/repos/wolfeman67/node-ari-shared-line-appearances/assignees{/user}","branches_url":"https://api.github.com/repos/wolfeman67/node-ari-shared-line-appearances/branches{/branch}","tags_url":"https://api.github.com/repos/wolfeman67/node-ari-shared-line-appearances/tags","blobs_url":"https://api.github.com/repos/wolfeman67/node-ari-shared-line-appearances/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/wolfeman67/node-ari-shared-line-appearances/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/wolfeman67/node-ari-shared-line-appearances/git/refs{/sha}","trees_url":"https://api.github.com/repos/wolfeman67/node-ari-shared-line-appearances/git/trees{/sha}","statuses_url":"https://api.github.com/repos/wolfeman67/node-ari-shared-line-appearances/statuses/{sha}","languages_url":"https://api.github.com/repos/wolfeman67/node-ari-shared-line-appearances/languages","stargazers_url":"https://api.github.com/repos/wolfeman67/node-ari-shared-line-appearances/stargazers","contributors_url":"https://api.github.com/repos/wolfeman67/node-ari-shared-line-appearances/contributors","subscribers_url":"https://api.github.com/repos/wolfeman67/node-ari-shared-line-appearances/subscribers","subscription_url":"https://api.github.com/repos/wolfeman67/node-ari-shared-line-appearances/subscription","commits_url":"https://api.github.com/repos/wolfeman67/node-ari-shared-line-appearances/commits{/sha}","git_commits_url":"https://api.github.com/repos/wolfeman67/node-ari-shared-line-appearances/git/commits{/sha}","comments_url":"https://api.github.com/repos/wolfeman67/node-ari-shared-line-appearances/comments{/number}","issue_comment_url":"https://api.github.com/repos/wolfeman67/node-ari-shared-line-appearances/issues/comments{/number}","contents_url":"https://api.github.com/repos/wolfeman67/node-ari-shared-line-appearances/contents/{+path}","compare_url":"https://api.github.com/repos/wolfeman67/node-ari-shared-line-appearances/compare/{base}...{head}","merges_url":"https://api.github.com/repos/wolfeman67/node-ari-shared-line-appearances/merges","archive_url":"https://api.github.com/repos/wolfeman67/node-ari-shared-line-appearances/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/wolfeman67/node-ari-shared-line-appearances/downloads","issues_url":"https://api.github.com/repos/wolfeman67/node-ari-shared-line-appearances/issues{/number}","pulls_url":"https://api.github.com/repos/wolfeman67/node-ari-shared-line-appearances/pulls{/number}","milestones_url":"https://api.github.com/repos/wolfeman67/node-ari-shared-line-appearances/milestones{/number}","notifications_url":"https://api.github.com/repos/wolfeman67/node-ari-shared-line-appearances/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/wolfeman67/node-ari-shared-line-appearances/labels{/name}","releases_url":"https://api.github.com/repos/wolfeman67/node-ari-shared-line-appearances/releases{/id}","created_at":"2015-02-02T21:23:52Z","updated_at":"2015-04-03T19:20:45Z","pushed_at":"2015-04-09T21:58:54Z","git_url":"git://github.com/wolfeman67/node-ari-shared-line-appearances.git","ssh_url":"git@github.com:wolfeman67/node-ari-shared-line-appearances.git","clone_url":"https://github.com/wolfeman67/node-ari-shared-line-appearances.git","svn_url":"https://github.com/wolfeman67/node-ari-shared-line-appearances","homepage":null,"size":861,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":2,"forks":1,"open_issues":2,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/wolfeman67/node-ari-shared-line-appearances/pulls/20"},"html":{"href":"https://github.com/wolfeman67/node-ari-shared-line-appearances/pull/20"},"issue":{"href":"https://api.github.com/repos/wolfeman67/node-ari-shared-line-appearances/issues/20"},"comments":{"href":"https://api.github.com/repos/wolfeman67/node-ari-shared-line-appearances/issues/20/comments"},"review_comments":{"href":"https://api.github.com/repos/wolfeman67/node-ari-shared-line-appearances/pulls/20/comments"},"review_comment":{"href":"https://api.github.com/repos/wolfeman67/node-ari-shared-line-appearances/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/wolfeman67/node-ari-shared-line-appearances/pulls/20/commits"},"statuses":{"href":"https://api.github.com/repos/wolfeman67/node-ari-shared-line-appearances/statuses/12e1cbd47cc46aa319a0763f417fe8c812fb804c"}}}}