{"action":"created","comment":{"url":"https://api.github.com/repos/webex/spark-js-sdk/pulls/comments/236712343","pull_request_review_id":178840683,"id":236712343,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIzNjcxMjM0Mw==","diff_hunk":"@@ -0,0 +1,99 @@\n+import StateMachine from 'javascript-state-machine';\n+import StateMachineHistory from 'javascript-state-machine/lib/history';\n+\n+import Media from '../media';\n+import MeetingUtil from '../meeting/util';\n+import {MEETING_AUDIO_STATE_MACHINE, EVENT_TRIGGERS, EVENT_TYPES} from '../constants';\n+\n+const handleTransition = (value, audio, meeting) => {\n+  if (audio.mute && audio.self) {\n+    value = MEETING_AUDIO_STATE_MACHINE.STATES.MUTE_SELF;\n+  }\n+  if (!audio.mute && audio.self) {\n+    value = MEETING_AUDIO_STATE_MACHINE.STATES.UNMUTE_SELF;\n+  }\n+  return value;\n+};\n+\n+const AudioStateMachine = {\n+  create() {\n+    return new StateMachine({\n+      transitions: [\n+        {\n+          name: MEETING_AUDIO_STATE_MACHINE.TRANSITIONS.INIT,\n+          from: '*',\n+          to: function (audio, meeting) {\n+            return handleTransition(this.state, audio, meeting);\n+          }\n+        },\n+        {\n+          name: MEETING_AUDIO_STATE_MACHINE.TRANSITIONS.TOGGLE,\n+          from: '*',\n+          to: function (audio, meeting) {\n+            return handleTransition(this.state, audio, meeting);\n+          }\n+        }\n+      ],\n+      data: {\n+        muted: undefined,\n+        self: undefined\n+      },\n+      methods: {\n+        getMuted() {\n+          return this.muted;\n+        },\n+        getSelf() {\n+          return this.self;\n+        },\n+        onAfterInit(transition, audio, meeting) {\n+          this.muted = audio.mute;\n+          this.self = audio.self;\n+          meeting.trigger(EVENT_TRIGGERS.MEDIA_AUDIO, {\n+            type: EVENT_TYPES.local,\n+            status: this.state,\n+            muted: this.muted,\n+            action: MEETING_AUDIO_STATE_MACHINE.TRANSITIONS.INIT\n+          });\n+          console.log(`audio:state#onAfterInit->${transition.event} fired! State changed from '${transition.from}' to '${transition.to}' with transition '${transition.transition}''.`);\n+        },\n+        onAfterHistoryBack(transition, meeting, error) {\n+          meeting.trigger(EVENT_TRIGGERS.MEDIA_AUDIO, {\n+            type: EVENT_TYPES.ERROR,\n+            status: this.state,\n+            muted: this.muted,\n+            action: MEETING_AUDIO_STATE_MACHINE.TRANSITIONS.TOGGLE,\n+            error\n+          });\n+          console.log(`audio:state#onAfterHistoryBack->${transition.event} fired! State failed to change with transition '${transition.transition}''. State has been reset to ${this.history[this.history.length - 1]} and toggling has been reversed.`);\n+        },\n+        onAfterToggle(transition, audio, meeting) {\n+          if (audio.self) {\n+            this.self = true;\n+          }\n+          if (transition.from !== transition.to) {\n+            MeetingUtil.remoteUpdateAudioVideo(audio, {mute: meeting.video.muted}, meeting)\n+              .then((resolution) => {\n+                Media.localTracks(audio, {mute: meeting.video.muted}, meeting.localMediaStream);\n+                this.muted = audio.mute;","path":"packages/node_modules/@webex/plugin-meetings/src/meeting/audio.js","position":77,"original_position":77,"commit_id":"550baddca8ce79edbf76786a5fa209b5b0e051b7","original_commit_id":"550baddca8ce79edbf76786a5fa209b5b0e051b7","user":{"login":"andrewholsted","id":2391772,"node_id":"MDQ6VXNlcjIzOTE3NzI=","avatar_url":"https://avatars2.githubusercontent.com/u/2391772?v=4","gravatar_id":"","url":"https://api.github.com/users/andrewholsted","html_url":"https://github.com/andrewholsted","followers_url":"https://api.github.com/users/andrewholsted/followers","following_url":"https://api.github.com/users/andrewholsted/following{/other_user}","gists_url":"https://api.github.com/users/andrewholsted/gists{/gist_id}","starred_url":"https://api.github.com/users/andrewholsted/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andrewholsted/subscriptions","organizations_url":"https://api.github.com/users/andrewholsted/orgs","repos_url":"https://api.github.com/users/andrewholsted/repos","events_url":"https://api.github.com/users/andrewholsted/events{/privacy}","received_events_url":"https://api.github.com/users/andrewholsted/received_events","type":"User","site_admin":false},"body":"What happens if `Media.localTracks` fails to mute here? Will out state get out of sync?","created_at":"2018-11-27T15:25:17Z","updated_at":"2018-11-27T15:36:02Z","html_url":"https://github.com/webex/spark-js-sdk/pull/1037#discussion_r236712343","pull_request_url":"https://api.github.com/repos/webex/spark-js-sdk/pulls/1037","author_association":"NONE","_links":{"self":{"href":"https://api.github.com/repos/webex/spark-js-sdk/pulls/comments/236712343"},"html":{"href":"https://github.com/webex/spark-js-sdk/pull/1037#discussion_r236712343"},"pull_request":{"href":"https://api.github.com/repos/webex/spark-js-sdk/pulls/1037"}}},"pull_request":{"url":"https://api.github.com/repos/webex/spark-js-sdk/pulls/1037","id":233812824,"node_id":"MDExOlB1bGxSZXF1ZXN0MjMzODEyODI0","html_url":"https://github.com/webex/spark-js-sdk/pull/1037","diff_url":"https://github.com/webex/spark-js-sdk/pull/1037.diff","patch_url":"https://github.com/webex/spark-js-sdk/pull/1037.patch","issue_url":"https://api.github.com/repos/webex/spark-js-sdk/issues/1037","number":1037,"state":"open","locked":false,"title":"Mute v2","user":{"login":"chrisadubois","id":12264933,"node_id":"MDQ6VXNlcjEyMjY0OTMz","avatar_url":"https://avatars2.githubusercontent.com/u/12264933?v=4","gravatar_id":"","url":"https://api.github.com/users/chrisadubois","html_url":"https://github.com/chrisadubois","followers_url":"https://api.github.com/users/chrisadubois/followers","following_url":"https://api.github.com/users/chrisadubois/following{/other_user}","gists_url":"https://api.github.com/users/chrisadubois/gists{/gist_id}","starred_url":"https://api.github.com/users/chrisadubois/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chrisadubois/subscriptions","organizations_url":"https://api.github.com/users/chrisadubois/orgs","repos_url":"https://api.github.com/users/chrisadubois/repos","events_url":"https://api.github.com/users/chrisadubois/events{/privacy}","received_events_url":"https://api.github.com/users/chrisadubois/received_events","type":"User","site_admin":false},"body":"\r\n","created_at":"2018-11-27T08:01:56Z","updated_at":"2018-11-27T15:36:02Z","closed_at":null,"merged_at":null,"merge_commit_sha":"8112b486dce0a35d751236833338201f9631ffbe","assignee":null,"assignees":[],"requested_reviewers":[{"login":"mattnorris","id":2898571,"node_id":"MDQ6VXNlcjI4OTg1NzE=","avatar_url":"https://avatars3.githubusercontent.com/u/2898571?v=4","gravatar_id":"","url":"https://api.github.com/users/mattnorris","html_url":"https://github.com/mattnorris","followers_url":"https://api.github.com/users/mattnorris/followers","following_url":"https://api.github.com/users/mattnorris/following{/other_user}","gists_url":"https://api.github.com/users/mattnorris/gists{/gist_id}","starred_url":"https://api.github.com/users/mattnorris/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mattnorris/subscriptions","organizations_url":"https://api.github.com/users/mattnorris/orgs","repos_url":"https://api.github.com/users/mattnorris/repos","events_url":"https://api.github.com/users/mattnorris/events{/privacy}","received_events_url":"https://api.github.com/users/mattnorris/received_events","type":"User","site_admin":false},{"login":"arun3528","id":3895486,"node_id":"MDQ6VXNlcjM4OTU0ODY=","avatar_url":"https://avatars3.githubusercontent.com/u/3895486?v=4","gravatar_id":"","url":"https://api.github.com/users/arun3528","html_url":"https://github.com/arun3528","followers_url":"https://api.github.com/users/arun3528/followers","following_url":"https://api.github.com/users/arun3528/following{/other_user}","gists_url":"https://api.github.com/users/arun3528/gists{/gist_id}","starred_url":"https://api.github.com/users/arun3528/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/arun3528/subscriptions","organizations_url":"https://api.github.com/users/arun3528/orgs","repos_url":"https://api.github.com/users/arun3528/repos","events_url":"https://api.github.com/users/arun3528/events{/privacy}","received_events_url":"https://api.github.com/users/arun3528/received_events","type":"User","site_admin":false}],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/webex/spark-js-sdk/pulls/1037/commits","review_comments_url":"https://api.github.com/repos/webex/spark-js-sdk/pulls/1037/comments","review_comment_url":"https://api.github.com/repos/webex/spark-js-sdk/pulls/comments{/number}","comments_url":"https://api.github.com/repos/webex/spark-js-sdk/issues/1037/comments","statuses_url":"https://api.github.com/repos/webex/spark-js-sdk/statuses/550baddca8ce79edbf76786a5fa209b5b0e051b7","head":{"label":"chrisadubois:mute_v2","ref":"mute_v2","sha":"550baddca8ce79edbf76786a5fa209b5b0e051b7","user":{"login":"chrisadubois","id":12264933,"node_id":"MDQ6VXNlcjEyMjY0OTMz","avatar_url":"https://avatars2.githubusercontent.com/u/12264933?v=4","gravatar_id":"","url":"https://api.github.com/users/chrisadubois","html_url":"https://github.com/chrisadubois","followers_url":"https://api.github.com/users/chrisadubois/followers","following_url":"https://api.github.com/users/chrisadubois/following{/other_user}","gists_url":"https://api.github.com/users/chrisadubois/gists{/gist_id}","starred_url":"https://api.github.com/users/chrisadubois/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chrisadubois/subscriptions","organizations_url":"https://api.github.com/users/chrisadubois/orgs","repos_url":"https://api.github.com/users/chrisadubois/repos","events_url":"https://api.github.com/users/chrisadubois/events{/privacy}","received_events_url":"https://api.github.com/users/chrisadubois/received_events","type":"User","site_admin":false},"repo":{"id":139895267,"node_id":"MDEwOlJlcG9zaXRvcnkxMzk4OTUyNjc=","name":"spark-js-sdk","full_name":"chrisadubois/spark-js-sdk","private":false,"owner":{"login":"chrisadubois","id":12264933,"node_id":"MDQ6VXNlcjEyMjY0OTMz","avatar_url":"https://avatars2.githubusercontent.com/u/12264933?v=4","gravatar_id":"","url":"https://api.github.com/users/chrisadubois","html_url":"https://github.com/chrisadubois","followers_url":"https://api.github.com/users/chrisadubois/followers","following_url":"https://api.github.com/users/chrisadubois/following{/other_user}","gists_url":"https://api.github.com/users/chrisadubois/gists{/gist_id}","starred_url":"https://api.github.com/users/chrisadubois/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chrisadubois/subscriptions","organizations_url":"https://api.github.com/users/chrisadubois/orgs","repos_url":"https://api.github.com/users/chrisadubois/repos","events_url":"https://api.github.com/users/chrisadubois/events{/privacy}","received_events_url":"https://api.github.com/users/chrisadubois/received_events","type":"User","site_admin":false},"html_url":"https://github.com/chrisadubois/spark-js-sdk","description":"JavaScript SDK for Webex Teams","fork":true,"url":"https://api.github.com/repos/chrisadubois/spark-js-sdk","forks_url":"https://api.github.com/repos/chrisadubois/spark-js-sdk/forks","keys_url":"https://api.github.com/repos/chrisadubois/spark-js-sdk/keys{/key_id}","collaborators_url":"https://api.github.com/repos/chrisadubois/spark-js-sdk/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/chrisadubois/spark-js-sdk/teams","hooks_url":"https://api.github.com/repos/chrisadubois/spark-js-sdk/hooks","issue_events_url":"https://api.github.com/repos/chrisadubois/spark-js-sdk/issues/events{/number}","events_url":"https://api.github.com/repos/chrisadubois/spark-js-sdk/events","assignees_url":"https://api.github.com/repos/chrisadubois/spark-js-sdk/assignees{/user}","branches_url":"https://api.github.com/repos/chrisadubois/spark-js-sdk/branches{/branch}","tags_url":"https://api.github.com/repos/chrisadubois/spark-js-sdk/tags","blobs_url":"https://api.github.com/repos/chrisadubois/spark-js-sdk/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/chrisadubois/spark-js-sdk/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/chrisadubois/spark-js-sdk/git/refs{/sha}","trees_url":"https://api.github.com/repos/chrisadubois/spark-js-sdk/git/trees{/sha}","statuses_url":"https://api.github.com/repos/chrisadubois/spark-js-sdk/statuses/{sha}","languages_url":"https://api.github.com/repos/chrisadubois/spark-js-sdk/languages","stargazers_url":"https://api.github.com/repos/chrisadubois/spark-js-sdk/stargazers","contributors_url":"https://api.github.com/repos/chrisadubois/spark-js-sdk/contributors","subscribers_url":"https://api.github.com/repos/chrisadubois/spark-js-sdk/subscribers","subscription_url":"https://api.github.com/repos/chrisadubois/spark-js-sdk/subscription","commits_url":"https://api.github.com/repos/chrisadubois/spark-js-sdk/commits{/sha}","git_commits_url":"https://api.github.com/repos/chrisadubois/spark-js-sdk/git/commits{/sha}","comments_url":"https://api.github.com/repos/chrisadubois/spark-js-sdk/comments{/number}","issue_comment_url":"https://api.github.com/repos/chrisadubois/spark-js-sdk/issues/comments{/number}","contents_url":"https://api.github.com/repos/chrisadubois/spark-js-sdk/contents/{+path}","compare_url":"https://api.github.com/repos/chrisadubois/spark-js-sdk/compare/{base}...{head}","merges_url":"https://api.github.com/repos/chrisadubois/spark-js-sdk/merges","archive_url":"https://api.github.com/repos/chrisadubois/spark-js-sdk/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/chrisadubois/spark-js-sdk/downloads","issues_url":"https://api.github.com/repos/chrisadubois/spark-js-sdk/issues{/number}","pulls_url":"https://api.github.com/repos/chrisadubois/spark-js-sdk/pulls{/number}","milestones_url":"https://api.github.com/repos/chrisadubois/spark-js-sdk/milestones{/number}","notifications_url":"https://api.github.com/repos/chrisadubois/spark-js-sdk/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/chrisadubois/spark-js-sdk/labels{/name}","releases_url":"https://api.github.com/repos/chrisadubois/spark-js-sdk/releases{/id}","deployments_url":"https://api.github.com/repos/chrisadubois/spark-js-sdk/deployments","created_at":"2018-07-05T20:07:12Z","updated_at":"2018-07-05T20:07:14Z","pushed_at":"2018-11-27T08:09:16Z","git_url":"git://github.com/chrisadubois/spark-js-sdk.git","ssh_url":"git@github.com:chrisadubois/spark-js-sdk.git","clone_url":"https://github.com/chrisadubois/spark-js-sdk.git","svn_url":"https://github.com/chrisadubois/spark-js-sdk","homepage":"https://webex.github.io/spark-js-sdk/","size":44260,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"webex:meeting-phase1","ref":"meeting-phase1","sha":"b237f4408ddfab80eb7f203931222ac1ac940c72","user":{"login":"webex","id":15900782,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE1OTAwNzgy","avatar_url":"https://avatars0.githubusercontent.com/u/15900782?v=4","gravatar_id":"","url":"https://api.github.com/users/webex","html_url":"https://github.com/webex","followers_url":"https://api.github.com/users/webex/followers","following_url":"https://api.github.com/users/webex/following{/other_user}","gists_url":"https://api.github.com/users/webex/gists{/gist_id}","starred_url":"https://api.github.com/users/webex/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/webex/subscriptions","organizations_url":"https://api.github.com/users/webex/orgs","repos_url":"https://api.github.com/users/webex/repos","events_url":"https://api.github.com/users/webex/events{/privacy}","received_events_url":"https://api.github.com/users/webex/received_events","type":"Organization","site_admin":false},"repo":{"id":62836827,"node_id":"MDEwOlJlcG9zaXRvcnk2MjgzNjgyNw==","name":"spark-js-sdk","full_name":"webex/spark-js-sdk","private":false,"owner":{"login":"webex","id":15900782,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE1OTAwNzgy","avatar_url":"https://avatars0.githubusercontent.com/u/15900782?v=4","gravatar_id":"","url":"https://api.github.com/users/webex","html_url":"https://github.com/webex","followers_url":"https://api.github.com/users/webex/followers","following_url":"https://api.github.com/users/webex/following{/other_user}","gists_url":"https://api.github.com/users/webex/gists{/gist_id}","starred_url":"https://api.github.com/users/webex/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/webex/subscriptions","organizations_url":"https://api.github.com/users/webex/orgs","repos_url":"https://api.github.com/users/webex/repos","events_url":"https://api.github.com/users/webex/events{/privacy}","received_events_url":"https://api.github.com/users/webex/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/webex/spark-js-sdk","description":"JavaScript SDK for Webex Teams","fork":false,"url":"https://api.github.com/repos/webex/spark-js-sdk","forks_url":"https://api.github.com/repos/webex/spark-js-sdk/forks","keys_url":"https://api.github.com/repos/webex/spark-js-sdk/keys{/key_id}","collaborators_url":"https://api.github.com/repos/webex/spark-js-sdk/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/webex/spark-js-sdk/teams","hooks_url":"https://api.github.com/repos/webex/spark-js-sdk/hooks","issue_events_url":"https://api.github.com/repos/webex/spark-js-sdk/issues/events{/number}","events_url":"https://api.github.com/repos/webex/spark-js-sdk/events","assignees_url":"https://api.github.com/repos/webex/spark-js-sdk/assignees{/user}","branches_url":"https://api.github.com/repos/webex/spark-js-sdk/branches{/branch}","tags_url":"https://api.github.com/repos/webex/spark-js-sdk/tags","blobs_url":"https://api.github.com/repos/webex/spark-js-sdk/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/webex/spark-js-sdk/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/webex/spark-js-sdk/git/refs{/sha}","trees_url":"https://api.github.com/repos/webex/spark-js-sdk/git/trees{/sha}","statuses_url":"https://api.github.com/repos/webex/spark-js-sdk/statuses/{sha}","languages_url":"https://api.github.com/repos/webex/spark-js-sdk/languages","stargazers_url":"https://api.github.com/repos/webex/spark-js-sdk/stargazers","contributors_url":"https://api.github.com/repos/webex/spark-js-sdk/contributors","subscribers_url":"https://api.github.com/repos/webex/spark-js-sdk/subscribers","subscription_url":"https://api.github.com/repos/webex/spark-js-sdk/subscription","commits_url":"https://api.github.com/repos/webex/spark-js-sdk/commits{/sha}","git_commits_url":"https://api.github.com/repos/webex/spark-js-sdk/git/commits{/sha}","comments_url":"https://api.github.com/repos/webex/spark-js-sdk/comments{/number}","issue_comment_url":"https://api.github.com/repos/webex/spark-js-sdk/issues/comments{/number}","contents_url":"https://api.github.com/repos/webex/spark-js-sdk/contents/{+path}","compare_url":"https://api.github.com/repos/webex/spark-js-sdk/compare/{base}...{head}","merges_url":"https://api.github.com/repos/webex/spark-js-sdk/merges","archive_url":"https://api.github.com/repos/webex/spark-js-sdk/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/webex/spark-js-sdk/downloads","issues_url":"https://api.github.com/repos/webex/spark-js-sdk/issues{/number}","pulls_url":"https://api.github.com/repos/webex/spark-js-sdk/pulls{/number}","milestones_url":"https://api.github.com/repos/webex/spark-js-sdk/milestones{/number}","notifications_url":"https://api.github.com/repos/webex/spark-js-sdk/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/webex/spark-js-sdk/labels{/name}","releases_url":"https://api.github.com/repos/webex/spark-js-sdk/releases{/id}","deployments_url":"https://api.github.com/repos/webex/spark-js-sdk/deployments","created_at":"2016-07-07T20:41:12Z","updated_at":"2018-11-26T16:58:13Z","pushed_at":"2018-11-27T08:09:17Z","git_url":"git://github.com/webex/spark-js-sdk.git","ssh_url":"git@github.com:webex/spark-js-sdk.git","clone_url":"https://github.com/webex/spark-js-sdk.git","svn_url":"https://github.com/webex/spark-js-sdk","homepage":"https://webex.github.io/spark-js-sdk/","size":45642,"stargazers_count":68,"watchers_count":68,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":90,"mirror_url":null,"archived":false,"open_issues_count":150,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":90,"open_issues":150,"watchers":68,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/webex/spark-js-sdk/pulls/1037"},"html":{"href":"https://github.com/webex/spark-js-sdk/pull/1037"},"issue":{"href":"https://api.github.com/repos/webex/spark-js-sdk/issues/1037"},"comments":{"href":"https://api.github.com/repos/webex/spark-js-sdk/issues/1037/comments"},"review_comments":{"href":"https://api.github.com/repos/webex/spark-js-sdk/pulls/1037/comments"},"review_comment":{"href":"https://api.github.com/repos/webex/spark-js-sdk/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/webex/spark-js-sdk/pulls/1037/commits"},"statuses":{"href":"https://api.github.com/repos/webex/spark-js-sdk/statuses/550baddca8ce79edbf76786a5fa209b5b0e051b7"}},"author_association":"NONE"}}
{"actor":{"display_login":"andrewholsted"}}