{"action":"created","comment":{"url":"https://api.github.com/repos/GPII/universal/pulls/comments/32421540","id":32421540,"diff_hunk":"@@ -0,0 +1,37 @@\n+(function () {\n+\n+    \"use strict\";\n+\n+    var fluid = require(\"infusion\");\n+    var gpii = fluid.registerNamespace(\"gpii\");\n+\n+    fluid.registerNamespace(\"gpii.request.flowManager\");\n+\n+    fluid.defaults(\"gpii.flowManager.browserChannel\", {\n+        gradeNames: [\"fluid.standardRelayComponent\", \"autoInit\"]\n+    });\n+\n+    fluid.defaults(\"kettle.requests.request.handler.browserChannel\", {\n+        gradeNames: [\"gpii.request.flowManager.sessionAware\", \"autoInit\"],\n+        invokers: {\n+            handle: {\n+                funcName: \"gpii.request.flowManager.browserChannelHandle\",\n+                args: [\"{request}\"],\n+                dynamic: true\n+            }\n+        }\n+    });\n+\n+    gpii.request.flowManager.browserChannelHandle = function (fluidRequest) {\n+        var data = fluidRequest.data;","path":"gpii/node_modules/flowManager/src/BrowserChannel.js","position":null,"original_position":26,"commit_id":"05b93274e9d23c552610b61048db5a8641450e4b","original_commit_id":"67a57a0460f6fdc818933af7c85932da0e6ff0a6","user":{"login":"javihernandez","id":821790,"avatar_url":"https://avatars.githubusercontent.com/u/821790?v=3","gravatar_id":"","url":"https://api.github.com/users/javihernandez","html_url":"https://github.com/javihernandez","followers_url":"https://api.github.com/users/javihernandez/followers","following_url":"https://api.github.com/users/javihernandez/following{/other_user}","gists_url":"https://api.github.com/users/javihernandez/gists{/gist_id}","starred_url":"https://api.github.com/users/javihernandez/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/javihernandez/subscriptions","organizations_url":"https://api.github.com/users/javihernandez/orgs","repos_url":"https://api.github.com/users/javihernandez/repos","events_url":"https://api.github.com/users/javihernandez/events{/privacy}","received_events_url":"https://api.github.com/users/javihernandez/received_events","type":"User","site_admin":false},"body":"> Should make some attempt to validate the data here. It should correspond to something in the solutions registry or at least be a string of the appropriate form - otherwise we are subject to obvious DoS attacks\r\n\r\n@amb26, \r\n\r\nI have added a check in [this commit](https://github.com/javihernandez/universal/commit/05b93274e9d23c552610b61048db5a8641450e4b). Although the client won't receive any messages from the webSockets settings handler, it's still \"connected\" to the system. How can I _break_ this connection? Is there any way to do this, or should I rely on the client to close the connection?","created_at":"2015-06-15T13:53:59Z","updated_at":"2015-06-15T13:53:59Z","html_url":"https://github.com/GPII/universal/pull/303#discussion_r32421540","pull_request_url":"https://api.github.com/repos/GPII/universal/pulls/303","_links":{"self":{"href":"https://api.github.com/repos/GPII/universal/pulls/comments/32421540"},"html":{"href":"https://github.com/GPII/universal/pull/303#discussion_r32421540"},"pull_request":{"href":"https://api.github.com/repos/GPII/universal/pulls/303"}}},"pull_request":{"url":"https://api.github.com/repos/GPII/universal/pulls/303","id":26541856,"html_url":"https://github.com/GPII/universal/pull/303","diff_url":"https://github.com/GPII/universal/pull/303.diff","patch_url":"https://github.com/GPII/universal/pull/303.patch","issue_url":"https://api.github.com/repos/GPII/universal/issues/303","number":303,"state":"open","locked":false,"title":"GPII-989: Adding FlowManager's browserChannel and WebSockets settings handler","user":{"login":"javihernandez","id":821790,"avatar_url":"https://avatars.githubusercontent.com/u/821790?v=3","gravatar_id":"","url":"https://api.github.com/users/javihernandez","html_url":"https://github.com/javihernandez","followers_url":"https://api.github.com/users/javihernandez/followers","following_url":"https://api.github.com/users/javihernandez/following{/other_user}","gists_url":"https://api.github.com/users/javihernandez/gists{/gist_id}","starred_url":"https://api.github.com/users/javihernandez/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/javihernandez/subscriptions","organizations_url":"https://api.github.com/users/javihernandez/orgs","repos_url":"https://api.github.com/users/javihernandez/repos","events_url":"https://api.github.com/users/javihernandez/events{/privacy}","received_events_url":"https://api.github.com/users/javihernandez/received_events","type":"User","site_admin":false},"body":"## Description of changes and additions in this pull request\r\n\r\nThis pull request consists on *two parts*:\r\n\r\n1. A new route in the flow manager, the *browserChannel*\r\n2. The new *WebSockets settings handler*\r\n\r\n### The browser channel\r\nThis new route can be reached at _http://localhost:8081/browserChannel_\r\nwhere our web socket server is listening for new clients (browsers).\r\nThis new route's handler takes care of:\r\n1. Registering new clients (browsers)\r\n2. Delivering the requested settings to the new client (if any) right after the connection happens\r\n3. Making sure that the client will be removed from the system after being disconnected\r\n\r\n### The WebSockets settings handler\r\nThis new settings handler is where lives all the logic behind the browser channel, since it is who keeps in memory both the settings and the registered clients.\r\n\r\n## How it works?\r\n\r\nThis small and documented client illustrates the workflow.\r\n\r\n```javascript\r\nvar io = require(\"socket.io-client\");\r\n\r\n// The client starts the communication\r\n//\r\nvar socket = io.connect(\"http://localhost:8081/browserChannel\");\r\n\r\n// When the connection is done, the client tells to the flow manager its id\r\n//\r\nsocket.on(\"connect\", function () {\r\n    console.log(\"## Socket connected\");\r\n    socket.send(\"org.chrome.cloud4chrome\");\r\n});\r\n \r\n// Right after sending the id to the flow manager, the server will return back\r\n// the current settings in the system (if any)\r\n//\r\nsocket.on(\"connectionSucceeded\", function (settings) {\r\n    console.log(\"## Received the following settings: \" + JSON.stringify(settings));\r\n});\r\n \r\n// By listening to this signal, the client will be notified when the system has\r\n// new settings to be applied on the client side\r\n//\r\nsocket.on(\"onBrowserSettingsChanged\", function (newSettings) {\r\n    console.log(\"## Got newSettings: \" + JSON.stringify(newSettings));\r\n});\r\n```\r\n\r\nThe _contract API_ between client and server can be explained as follows:\r\n\r\n* After connecting to the flow manager, the client sends a socket message to the channel, which is basically a string containing the *id* of the client. ie: _org.chrome.cloud4chrome_\r\n\r\n* When the flow manager emits either the _connectionSucceeded_ (after being registered) or the _onBrowserSettingsChanged_ (after a user login/logout) signal to the client, it is delivering the current available settings for the client in the following way: \r\n```\r\n{\r\n    \"screenReaderTTSEnabled\":false,\r\n    \"highContrastEnabled\":true,\r\n    \"invertColours\":false,\r\n    \"magnifierEnabled\":true,\r\n    \"magnification\":2,\r\n    \"fontSize\":\"medium\",\r\n    \"simplifier\":false,\r\n    \"highContrastTheme\":\"white-black\"\r\n}\r\n```\r\n\r\n## Testing\r\n\r\nThis new feature can be seen in action by using this extension https://github.com/GutiX/chrome4cloud/commit/3d064bb7efc93bf90fde90b0192c273fb76817e5\r\n\r\nRight now this pull request includes a very basic solution entry for GNU/Linux (https://github.com/javihernandez/universal/blob/GPII-989/testData/solutions/linux.json#L1332-L1356), so if you want to test it either on Windows or Mac, you will need to include the same entry in the corresponding solution registry of your platform.\r\n\r\n","created_at":"2014-12-24T02:07:21Z","updated_at":"2015-06-15T13:53:59Z","closed_at":null,"merged_at":null,"merge_commit_sha":"9974e19676b9b0dcac06af30ec762bcae5c79af8","assignee":{"login":"amb26","id":561418,"avatar_url":"https://avatars.githubusercontent.com/u/561418?v=3","gravatar_id":"","url":"https://api.github.com/users/amb26","html_url":"https://github.com/amb26","followers_url":"https://api.github.com/users/amb26/followers","following_url":"https://api.github.com/users/amb26/following{/other_user}","gists_url":"https://api.github.com/users/amb26/gists{/gist_id}","starred_url":"https://api.github.com/users/amb26/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/amb26/subscriptions","organizations_url":"https://api.github.com/users/amb26/orgs","repos_url":"https://api.github.com/users/amb26/repos","events_url":"https://api.github.com/users/amb26/events{/privacy}","received_events_url":"https://api.github.com/users/amb26/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/GPII/universal/pulls/303/commits","review_comments_url":"https://api.github.com/repos/GPII/universal/pulls/303/comments","review_comment_url":"https://api.github.com/repos/GPII/universal/pulls/comments{/number}","comments_url":"https://api.github.com/repos/GPII/universal/issues/303/comments","statuses_url":"https://api.github.com/repos/GPII/universal/statuses/05b93274e9d23c552610b61048db5a8641450e4b","head":{"label":"javihernandez:GPII-989","ref":"GPII-989","sha":"05b93274e9d23c552610b61048db5a8641450e4b","user":{"login":"javihernandez","id":821790,"avatar_url":"https://avatars.githubusercontent.com/u/821790?v=3","gravatar_id":"","url":"https://api.github.com/users/javihernandez","html_url":"https://github.com/javihernandez","followers_url":"https://api.github.com/users/javihernandez/followers","following_url":"https://api.github.com/users/javihernandez/following{/other_user}","gists_url":"https://api.github.com/users/javihernandez/gists{/gist_id}","starred_url":"https://api.github.com/users/javihernandez/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/javihernandez/subscriptions","organizations_url":"https://api.github.com/users/javihernandez/orgs","repos_url":"https://api.github.com/users/javihernandez/repos","events_url":"https://api.github.com/users/javihernandez/events{/privacy}","received_events_url":"https://api.github.com/users/javihernandez/received_events","type":"User","site_admin":false},"repo":{"id":4546102,"name":"universal","full_name":"javihernandez/universal","owner":{"login":"javihernandez","id":821790,"avatar_url":"https://avatars.githubusercontent.com/u/821790?v=3","gravatar_id":"","url":"https://api.github.com/users/javihernandez","html_url":"https://github.com/javihernandez","followers_url":"https://api.github.com/users/javihernandez/followers","following_url":"https://api.github.com/users/javihernandez/following{/other_user}","gists_url":"https://api.github.com/users/javihernandez/gists{/gist_id}","starred_url":"https://api.github.com/users/javihernandez/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/javihernandez/subscriptions","organizations_url":"https://api.github.com/users/javihernandez/orgs","repos_url":"https://api.github.com/users/javihernandez/repos","events_url":"https://api.github.com/users/javihernandez/events{/privacy}","received_events_url":"https://api.github.com/users/javihernandez/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/javihernandez/universal","description":"Cross platform, core components of the GPII personalization infrastructure","fork":true,"url":"https://api.github.com/repos/javihernandez/universal","forks_url":"https://api.github.com/repos/javihernandez/universal/forks","keys_url":"https://api.github.com/repos/javihernandez/universal/keys{/key_id}","collaborators_url":"https://api.github.com/repos/javihernandez/universal/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/javihernandez/universal/teams","hooks_url":"https://api.github.com/repos/javihernandez/universal/hooks","issue_events_url":"https://api.github.com/repos/javihernandez/universal/issues/events{/number}","events_url":"https://api.github.com/repos/javihernandez/universal/events","assignees_url":"https://api.github.com/repos/javihernandez/universal/assignees{/user}","branches_url":"https://api.github.com/repos/javihernandez/universal/branches{/branch}","tags_url":"https://api.github.com/repos/javihernandez/universal/tags","blobs_url":"https://api.github.com/repos/javihernandez/universal/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/javihernandez/universal/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/javihernandez/universal/git/refs{/sha}","trees_url":"https://api.github.com/repos/javihernandez/universal/git/trees{/sha}","statuses_url":"https://api.github.com/repos/javihernandez/universal/statuses/{sha}","languages_url":"https://api.github.com/repos/javihernandez/universal/languages","stargazers_url":"https://api.github.com/repos/javihernandez/universal/stargazers","contributors_url":"https://api.github.com/repos/javihernandez/universal/contributors","subscribers_url":"https://api.github.com/repos/javihernandez/universal/subscribers","subscription_url":"https://api.github.com/repos/javihernandez/universal/subscription","commits_url":"https://api.github.com/repos/javihernandez/universal/commits{/sha}","git_commits_url":"https://api.github.com/repos/javihernandez/universal/git/commits{/sha}","comments_url":"https://api.github.com/repos/javihernandez/universal/comments{/number}","issue_comment_url":"https://api.github.com/repos/javihernandez/universal/issues/comments{/number}","contents_url":"https://api.github.com/repos/javihernandez/universal/contents/{+path}","compare_url":"https://api.github.com/repos/javihernandez/universal/compare/{base}...{head}","merges_url":"https://api.github.com/repos/javihernandez/universal/merges","archive_url":"https://api.github.com/repos/javihernandez/universal/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/javihernandez/universal/downloads","issues_url":"https://api.github.com/repos/javihernandez/universal/issues{/number}","pulls_url":"https://api.github.com/repos/javihernandez/universal/pulls{/number}","milestones_url":"https://api.github.com/repos/javihernandez/universal/milestones{/number}","notifications_url":"https://api.github.com/repos/javihernandez/universal/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/javihernandez/universal/labels{/name}","releases_url":"https://api.github.com/repos/javihernandez/universal/releases{/id}","created_at":"2012-06-04T10:50:43Z","updated_at":"2015-05-05T15:04:00Z","pushed_at":"2015-06-15T13:49:30Z","git_url":"git://github.com/javihernandez/universal.git","ssh_url":"git@github.com:javihernandez/universal.git","clone_url":"https://github.com/javihernandez/universal.git","svn_url":"https://github.com/javihernandez/universal","homepage":"gpii.net","size":92336,"stargazers_count":1,"watchers_count":1,"language":"JavaScript","has_issues":false,"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":1,"default_branch":"master"}},"base":{"label":"GPII:master","ref":"master","sha":"644922a9e50d4ff68993cf1a1fd2e2fbf68d28f6","user":{"login":"GPII","id":1343050,"avatar_url":"https://avatars.githubusercontent.com/u/1343050?v=3","gravatar_id":"","url":"https://api.github.com/users/GPII","html_url":"https://github.com/GPII","followers_url":"https://api.github.com/users/GPII/followers","following_url":"https://api.github.com/users/GPII/following{/other_user}","gists_url":"https://api.github.com/users/GPII/gists{/gist_id}","starred_url":"https://api.github.com/users/GPII/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/GPII/subscriptions","organizations_url":"https://api.github.com/users/GPII/orgs","repos_url":"https://api.github.com/users/GPII/repos","events_url":"https://api.github.com/users/GPII/events{/privacy}","received_events_url":"https://api.github.com/users/GPII/received_events","type":"Organization","site_admin":false},"repo":{"id":3623720,"name":"universal","full_name":"GPII/universal","owner":{"login":"GPII","id":1343050,"avatar_url":"https://avatars.githubusercontent.com/u/1343050?v=3","gravatar_id":"","url":"https://api.github.com/users/GPII","html_url":"https://github.com/GPII","followers_url":"https://api.github.com/users/GPII/followers","following_url":"https://api.github.com/users/GPII/following{/other_user}","gists_url":"https://api.github.com/users/GPII/gists{/gist_id}","starred_url":"https://api.github.com/users/GPII/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/GPII/subscriptions","organizations_url":"https://api.github.com/users/GPII/orgs","repos_url":"https://api.github.com/users/GPII/repos","events_url":"https://api.github.com/users/GPII/events{/privacy}","received_events_url":"https://api.github.com/users/GPII/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/GPII/universal","description":"Cross platform, core components of the GPII personalization infrastructure","fork":false,"url":"https://api.github.com/repos/GPII/universal","forks_url":"https://api.github.com/repos/GPII/universal/forks","keys_url":"https://api.github.com/repos/GPII/universal/keys{/key_id}","collaborators_url":"https://api.github.com/repos/GPII/universal/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/GPII/universal/teams","hooks_url":"https://api.github.com/repos/GPII/universal/hooks","issue_events_url":"https://api.github.com/repos/GPII/universal/issues/events{/number}","events_url":"https://api.github.com/repos/GPII/universal/events","assignees_url":"https://api.github.com/repos/GPII/universal/assignees{/user}","branches_url":"https://api.github.com/repos/GPII/universal/branches{/branch}","tags_url":"https://api.github.com/repos/GPII/universal/tags","blobs_url":"https://api.github.com/repos/GPII/universal/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/GPII/universal/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/GPII/universal/git/refs{/sha}","trees_url":"https://api.github.com/repos/GPII/universal/git/trees{/sha}","statuses_url":"https://api.github.com/repos/GPII/universal/statuses/{sha}","languages_url":"https://api.github.com/repos/GPII/universal/languages","stargazers_url":"https://api.github.com/repos/GPII/universal/stargazers","contributors_url":"https://api.github.com/repos/GPII/universal/contributors","subscribers_url":"https://api.github.com/repos/GPII/universal/subscribers","subscription_url":"https://api.github.com/repos/GPII/universal/subscription","commits_url":"https://api.github.com/repos/GPII/universal/commits{/sha}","git_commits_url":"https://api.github.com/repos/GPII/universal/git/commits{/sha}","comments_url":"https://api.github.com/repos/GPII/universal/comments{/number}","issue_comment_url":"https://api.github.com/repos/GPII/universal/issues/comments{/number}","contents_url":"https://api.github.com/repos/GPII/universal/contents/{+path}","compare_url":"https://api.github.com/repos/GPII/universal/compare/{base}...{head}","merges_url":"https://api.github.com/repos/GPII/universal/merges","archive_url":"https://api.github.com/repos/GPII/universal/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/GPII/universal/downloads","issues_url":"https://api.github.com/repos/GPII/universal/issues{/number}","pulls_url":"https://api.github.com/repos/GPII/universal/pulls{/number}","milestones_url":"https://api.github.com/repos/GPII/universal/milestones{/number}","notifications_url":"https://api.github.com/repos/GPII/universal/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/GPII/universal/labels{/name}","releases_url":"https://api.github.com/repos/GPII/universal/releases{/id}","created_at":"2012-03-05T04:01:44Z","updated_at":"2015-06-03T18:28:28Z","pushed_at":"2015-06-15T13:49:30Z","git_url":"git://github.com/GPII/universal.git","ssh_url":"git@github.com:GPII/universal.git","clone_url":"https://github.com/GPII/universal.git","svn_url":"https://github.com/GPII/universal","homepage":"gpii.net","size":94260,"stargazers_count":21,"watchers_count":21,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":46,"mirror_url":null,"open_issues_count":31,"forks":46,"open_issues":31,"watchers":21,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/GPII/universal/pulls/303"},"html":{"href":"https://github.com/GPII/universal/pull/303"},"issue":{"href":"https://api.github.com/repos/GPII/universal/issues/303"},"comments":{"href":"https://api.github.com/repos/GPII/universal/issues/303/comments"},"review_comments":{"href":"https://api.github.com/repos/GPII/universal/pulls/303/comments"},"review_comment":{"href":"https://api.github.com/repos/GPII/universal/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/GPII/universal/pulls/303/commits"},"statuses":{"href":"https://api.github.com/repos/GPII/universal/statuses/05b93274e9d23c552610b61048db5a8641450e4b"}}}}