{"action":"created","comment":{"url":"https://api.github.com/repos/Cardshifter/HTML-Client/pulls/comments/41088700","id":41088700,"diff_hunk":"@@ -289,26 +290,24 @@ var CardshifterServerAPI = {\n     },\n \n     /**\n-    * Sets an event listener for when the server sends a message and\n-    * the message type is one of the types in types\n+    * Sets an event listener for when the server sends a message\n+    * and the message command is one of the keys in the commandMap\n     *\n-    * @param listener:Function -- The function to fire when a message of types is received\n-    * @param types:[string] (OPTIONAL) -- Only fire the listener when the message type is in this array\n-    * @param timeout:Object (OPTIONAL) -- The function(.ontimeout) to call after MS(.ms) of no reply\n-    *\n-    * TODO: Maybe a timeout will be needed? Pass in a function and a MS count.\n+    * @param commandMap:Object -- The keys are the command types and the values are\n+    *       functions to run when a message of that command is encountered.\n+    * @param scope:$scope -- The scope of the controller running this.\n     */\n-    setMessageListener: function(listener, types) {\n-        eventTypes = types;\n-\n+    setMessageListener: function(commandMap, scope) {\n         this.socket.onmessage = function(message) {\n             var data = JSON.parse(message.data);\n-            if(eventTypes) {\n-                if(eventTypes.indexOf(data.command) !== -1) { // if contains\n-                    listener(data);\n-                }\n-            } else {\n-                listener(data);\n+            var command = data.command;\n+\n+            console.log(\"Received message\", data);","path":"src/server_interface/server_interface.js","position":58,"original_position":58,"commit_id":"f49738cdb2347a9db768fc7d6ccd1f631be11f74","original_commit_id":"f49738cdb2347a9db768fc7d6ccd1f631be11f74","user":{"login":"danpantry","id":2939173,"avatar_url":"https://avatars.githubusercontent.com/u/2939173?v=3","gravatar_id":"","url":"https://api.github.com/users/danpantry","html_url":"https://github.com/danpantry","followers_url":"https://api.github.com/users/danpantry/followers","following_url":"https://api.github.com/users/danpantry/following{/other_user}","gists_url":"https://api.github.com/users/danpantry/gists{/gist_id}","starred_url":"https://api.github.com/users/danpantry/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/danpantry/subscriptions","organizations_url":"https://api.github.com/users/danpantry/orgs","repos_url":"https://api.github.com/users/danpantry/repos","events_url":"https://api.github.com/users/danpantry/events{/privacy}","received_events_url":"https://api.github.com/users/danpantry/received_events","type":"User","site_admin":false},"body":"Hmm, okay. Then perhaps you could look at using [debug](https://www.npmjs.com/package/debug)?","created_at":"2015-10-03T16:21:25Z","updated_at":"2015-10-03T16:21:25Z","html_url":"https://github.com/Cardshifter/HTML-Client/pull/110#discussion_r41088700","pull_request_url":"https://api.github.com/repos/Cardshifter/HTML-Client/pulls/110","_links":{"self":{"href":"https://api.github.com/repos/Cardshifter/HTML-Client/pulls/comments/41088700"},"html":{"href":"https://github.com/Cardshifter/HTML-Client/pull/110#discussion_r41088700"},"pull_request":{"href":"https://api.github.com/repos/Cardshifter/HTML-Client/pulls/110"}}},"pull_request":{"url":"https://api.github.com/repos/Cardshifter/HTML-Client/pulls/110","id":46067031,"html_url":"https://github.com/Cardshifter/HTML-Client/pull/110","diff_url":"https://github.com/Cardshifter/HTML-Client/pull/110.diff","patch_url":"https://github.com/Cardshifter/HTML-Client/pull/110.patch","issue_url":"https://api.github.com/repos/Cardshifter/HTML-Client/issues/110","number":110,"state":"open","locked":false,"title":"Errors and new API","user":{"login":"SirPython","id":8549957,"avatar_url":"https://avatars.githubusercontent.com/u/8549957?v=3","gravatar_id":"","url":"https://api.github.com/users/SirPython","html_url":"https://github.com/SirPython","followers_url":"https://api.github.com/users/SirPython/followers","following_url":"https://api.github.com/users/SirPython/following{/other_user}","gists_url":"https://api.github.com/users/SirPython/gists{/gist_id}","starred_url":"https://api.github.com/users/SirPython/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SirPython/subscriptions","organizations_url":"https://api.github.com/users/SirPython/orgs","repos_url":"https://api.github.com/users/SirPython/repos","events_url":"https://api.github.com/users/SirPython/events{/privacy}","received_events_url":"https://api.github.com/users/SirPython/received_events","type":"User","site_admin":false},"body":"Created a system for displaying errors in a popup/modal.\r\n\r\nUpdated the API's `setMessageListener`","created_at":"2015-09-25T23:04:58Z","updated_at":"2015-10-03T16:21:25Z","closed_at":null,"merged_at":null,"merge_commit_sha":null,"assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/Cardshifter/HTML-Client/pulls/110/commits","review_comments_url":"https://api.github.com/repos/Cardshifter/HTML-Client/pulls/110/comments","review_comment_url":"https://api.github.com/repos/Cardshifter/HTML-Client/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Cardshifter/HTML-Client/issues/110/comments","statuses_url":"https://api.github.com/repos/Cardshifter/HTML-Client/statuses/f49738cdb2347a9db768fc7d6ccd1f631be11f74","head":{"label":"Cardshifter:errors","ref":"errors","sha":"f49738cdb2347a9db768fc7d6ccd1f631be11f74","user":{"login":"Cardshifter","id":8478053,"avatar_url":"https://avatars.githubusercontent.com/u/8478053?v=3","gravatar_id":"","url":"https://api.github.com/users/Cardshifter","html_url":"https://github.com/Cardshifter","followers_url":"https://api.github.com/users/Cardshifter/followers","following_url":"https://api.github.com/users/Cardshifter/following{/other_user}","gists_url":"https://api.github.com/users/Cardshifter/gists{/gist_id}","starred_url":"https://api.github.com/users/Cardshifter/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Cardshifter/subscriptions","organizations_url":"https://api.github.com/users/Cardshifter/orgs","repos_url":"https://api.github.com/users/Cardshifter/repos","events_url":"https://api.github.com/users/Cardshifter/events{/privacy}","received_events_url":"https://api.github.com/users/Cardshifter/received_events","type":"Organization","site_admin":false},"repo":{"id":39746630,"name":"HTML-Client","full_name":"Cardshifter/HTML-Client","owner":{"login":"Cardshifter","id":8478053,"avatar_url":"https://avatars.githubusercontent.com/u/8478053?v=3","gravatar_id":"","url":"https://api.github.com/users/Cardshifter","html_url":"https://github.com/Cardshifter","followers_url":"https://api.github.com/users/Cardshifter/followers","following_url":"https://api.github.com/users/Cardshifter/following{/other_user}","gists_url":"https://api.github.com/users/Cardshifter/gists{/gist_id}","starred_url":"https://api.github.com/users/Cardshifter/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Cardshifter/subscriptions","organizations_url":"https://api.github.com/users/Cardshifter/orgs","repos_url":"https://api.github.com/users/Cardshifter/repos","events_url":"https://api.github.com/users/Cardshifter/events{/privacy}","received_events_url":"https://api.github.com/users/Cardshifter/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Cardshifter/HTML-Client","description":"HTML/CSS/JS-based client for Cardshifter","fork":false,"url":"https://api.github.com/repos/Cardshifter/HTML-Client","forks_url":"https://api.github.com/repos/Cardshifter/HTML-Client/forks","keys_url":"https://api.github.com/repos/Cardshifter/HTML-Client/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Cardshifter/HTML-Client/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Cardshifter/HTML-Client/teams","hooks_url":"https://api.github.com/repos/Cardshifter/HTML-Client/hooks","issue_events_url":"https://api.github.com/repos/Cardshifter/HTML-Client/issues/events{/number}","events_url":"https://api.github.com/repos/Cardshifter/HTML-Client/events","assignees_url":"https://api.github.com/repos/Cardshifter/HTML-Client/assignees{/user}","branches_url":"https://api.github.com/repos/Cardshifter/HTML-Client/branches{/branch}","tags_url":"https://api.github.com/repos/Cardshifter/HTML-Client/tags","blobs_url":"https://api.github.com/repos/Cardshifter/HTML-Client/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Cardshifter/HTML-Client/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Cardshifter/HTML-Client/git/refs{/sha}","trees_url":"https://api.github.com/repos/Cardshifter/HTML-Client/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Cardshifter/HTML-Client/statuses/{sha}","languages_url":"https://api.github.com/repos/Cardshifter/HTML-Client/languages","stargazers_url":"https://api.github.com/repos/Cardshifter/HTML-Client/stargazers","contributors_url":"https://api.github.com/repos/Cardshifter/HTML-Client/contributors","subscribers_url":"https://api.github.com/repos/Cardshifter/HTML-Client/subscribers","subscription_url":"https://api.github.com/repos/Cardshifter/HTML-Client/subscription","commits_url":"https://api.github.com/repos/Cardshifter/HTML-Client/commits{/sha}","git_commits_url":"https://api.github.com/repos/Cardshifter/HTML-Client/git/commits{/sha}","comments_url":"https://api.github.com/repos/Cardshifter/HTML-Client/comments{/number}","issue_comment_url":"https://api.github.com/repos/Cardshifter/HTML-Client/issues/comments{/number}","contents_url":"https://api.github.com/repos/Cardshifter/HTML-Client/contents/{+path}","compare_url":"https://api.github.com/repos/Cardshifter/HTML-Client/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Cardshifter/HTML-Client/merges","archive_url":"https://api.github.com/repos/Cardshifter/HTML-Client/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Cardshifter/HTML-Client/downloads","issues_url":"https://api.github.com/repos/Cardshifter/HTML-Client/issues{/number}","pulls_url":"https://api.github.com/repos/Cardshifter/HTML-Client/pulls{/number}","milestones_url":"https://api.github.com/repos/Cardshifter/HTML-Client/milestones{/number}","notifications_url":"https://api.github.com/repos/Cardshifter/HTML-Client/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Cardshifter/HTML-Client/labels{/name}","releases_url":"https://api.github.com/repos/Cardshifter/HTML-Client/releases{/id}","created_at":"2015-07-26T23:54:19Z","updated_at":"2015-08-26T11:26:18Z","pushed_at":"2015-10-01T00:38:59Z","git_url":"git://github.com/Cardshifter/HTML-Client.git","ssh_url":"git@github.com:Cardshifter/HTML-Client.git","clone_url":"https://github.com/Cardshifter/HTML-Client.git","svn_url":"https://github.com/Cardshifter/HTML-Client","homepage":null,"size":9570,"stargazers_count":6,"watchers_count":6,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":3,"mirror_url":null,"open_issues_count":40,"forks":3,"open_issues":40,"watchers":6,"default_branch":"master"}},"base":{"label":"Cardshifter:develop","ref":"develop","sha":"53a133803bb756a3bb762f9ba174a3bef85efc81","user":{"login":"Cardshifter","id":8478053,"avatar_url":"https://avatars.githubusercontent.com/u/8478053?v=3","gravatar_id":"","url":"https://api.github.com/users/Cardshifter","html_url":"https://github.com/Cardshifter","followers_url":"https://api.github.com/users/Cardshifter/followers","following_url":"https://api.github.com/users/Cardshifter/following{/other_user}","gists_url":"https://api.github.com/users/Cardshifter/gists{/gist_id}","starred_url":"https://api.github.com/users/Cardshifter/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Cardshifter/subscriptions","organizations_url":"https://api.github.com/users/Cardshifter/orgs","repos_url":"https://api.github.com/users/Cardshifter/repos","events_url":"https://api.github.com/users/Cardshifter/events{/privacy}","received_events_url":"https://api.github.com/users/Cardshifter/received_events","type":"Organization","site_admin":false},"repo":{"id":39746630,"name":"HTML-Client","full_name":"Cardshifter/HTML-Client","owner":{"login":"Cardshifter","id":8478053,"avatar_url":"https://avatars.githubusercontent.com/u/8478053?v=3","gravatar_id":"","url":"https://api.github.com/users/Cardshifter","html_url":"https://github.com/Cardshifter","followers_url":"https://api.github.com/users/Cardshifter/followers","following_url":"https://api.github.com/users/Cardshifter/following{/other_user}","gists_url":"https://api.github.com/users/Cardshifter/gists{/gist_id}","starred_url":"https://api.github.com/users/Cardshifter/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Cardshifter/subscriptions","organizations_url":"https://api.github.com/users/Cardshifter/orgs","repos_url":"https://api.github.com/users/Cardshifter/repos","events_url":"https://api.github.com/users/Cardshifter/events{/privacy}","received_events_url":"https://api.github.com/users/Cardshifter/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Cardshifter/HTML-Client","description":"HTML/CSS/JS-based client for Cardshifter","fork":false,"url":"https://api.github.com/repos/Cardshifter/HTML-Client","forks_url":"https://api.github.com/repos/Cardshifter/HTML-Client/forks","keys_url":"https://api.github.com/repos/Cardshifter/HTML-Client/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Cardshifter/HTML-Client/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Cardshifter/HTML-Client/teams","hooks_url":"https://api.github.com/repos/Cardshifter/HTML-Client/hooks","issue_events_url":"https://api.github.com/repos/Cardshifter/HTML-Client/issues/events{/number}","events_url":"https://api.github.com/repos/Cardshifter/HTML-Client/events","assignees_url":"https://api.github.com/repos/Cardshifter/HTML-Client/assignees{/user}","branches_url":"https://api.github.com/repos/Cardshifter/HTML-Client/branches{/branch}","tags_url":"https://api.github.com/repos/Cardshifter/HTML-Client/tags","blobs_url":"https://api.github.com/repos/Cardshifter/HTML-Client/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Cardshifter/HTML-Client/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Cardshifter/HTML-Client/git/refs{/sha}","trees_url":"https://api.github.com/repos/Cardshifter/HTML-Client/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Cardshifter/HTML-Client/statuses/{sha}","languages_url":"https://api.github.com/repos/Cardshifter/HTML-Client/languages","stargazers_url":"https://api.github.com/repos/Cardshifter/HTML-Client/stargazers","contributors_url":"https://api.github.com/repos/Cardshifter/HTML-Client/contributors","subscribers_url":"https://api.github.com/repos/Cardshifter/HTML-Client/subscribers","subscription_url":"https://api.github.com/repos/Cardshifter/HTML-Client/subscription","commits_url":"https://api.github.com/repos/Cardshifter/HTML-Client/commits{/sha}","git_commits_url":"https://api.github.com/repos/Cardshifter/HTML-Client/git/commits{/sha}","comments_url":"https://api.github.com/repos/Cardshifter/HTML-Client/comments{/number}","issue_comment_url":"https://api.github.com/repos/Cardshifter/HTML-Client/issues/comments{/number}","contents_url":"https://api.github.com/repos/Cardshifter/HTML-Client/contents/{+path}","compare_url":"https://api.github.com/repos/Cardshifter/HTML-Client/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Cardshifter/HTML-Client/merges","archive_url":"https://api.github.com/repos/Cardshifter/HTML-Client/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Cardshifter/HTML-Client/downloads","issues_url":"https://api.github.com/repos/Cardshifter/HTML-Client/issues{/number}","pulls_url":"https://api.github.com/repos/Cardshifter/HTML-Client/pulls{/number}","milestones_url":"https://api.github.com/repos/Cardshifter/HTML-Client/milestones{/number}","notifications_url":"https://api.github.com/repos/Cardshifter/HTML-Client/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Cardshifter/HTML-Client/labels{/name}","releases_url":"https://api.github.com/repos/Cardshifter/HTML-Client/releases{/id}","created_at":"2015-07-26T23:54:19Z","updated_at":"2015-08-26T11:26:18Z","pushed_at":"2015-10-01T00:38:59Z","git_url":"git://github.com/Cardshifter/HTML-Client.git","ssh_url":"git@github.com:Cardshifter/HTML-Client.git","clone_url":"https://github.com/Cardshifter/HTML-Client.git","svn_url":"https://github.com/Cardshifter/HTML-Client","homepage":null,"size":9570,"stargazers_count":6,"watchers_count":6,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":3,"mirror_url":null,"open_issues_count":40,"forks":3,"open_issues":40,"watchers":6,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Cardshifter/HTML-Client/pulls/110"},"html":{"href":"https://github.com/Cardshifter/HTML-Client/pull/110"},"issue":{"href":"https://api.github.com/repos/Cardshifter/HTML-Client/issues/110"},"comments":{"href":"https://api.github.com/repos/Cardshifter/HTML-Client/issues/110/comments"},"review_comments":{"href":"https://api.github.com/repos/Cardshifter/HTML-Client/pulls/110/comments"},"review_comment":{"href":"https://api.github.com/repos/Cardshifter/HTML-Client/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Cardshifter/HTML-Client/pulls/110/commits"},"statuses":{"href":"https://api.github.com/repos/Cardshifter/HTML-Client/statuses/f49738cdb2347a9db768fc7d6ccd1f631be11f74"}}}}