{"action":"created","comment":{"url":"https://api.github.com/repos/Workiva/w_transport/pulls/comments/44562064","id":44562064,"diff_hunk":"@@ -0,0 +1,109 @@\n+// Copyright 2015 Workiva Inc.\n+//\n+// Licensed under the Apache License, Version 2.0 (the \"License\");\n+// you may not use this file except in compliance with the License.\n+// You may obtain a copy of the License at\n+//\n+//     http://www.apache.org/licenses/LICENSE-2.0\n+//\n+// Unless required by applicable law or agreed to in writing, software\n+// distributed under the License is distributed on an \"AS IS\" BASIS,\n+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n+// See the License for the specific language governing permissions and\n+// limitations under the License.\n+\n+library w_transport.src.web_socket.browser.sockjs;\n+\n+import 'dart:async';\n+import 'dart:html';\n+import 'dart:typed_data';\n+\n+import 'package:sockjs_client/sockjs_client.dart' as sockjs;\n+\n+import 'package:w_transport/src/web_socket/common/w_socket.dart';\n+import 'package:w_transport/src/web_socket/w_socket.dart';\n+import 'package:w_transport/src/web_socket/w_socket_close_event.dart';\n+import 'package:w_transport/src/web_socket/w_socket_exception.dart';\n+\n+class SockJSSocket extends CommonWSocket implements WSocket {\n+  static Future<WSocket> connect(Uri uri,\n+      {bool debug: false,\n+      bool noCredentials: false,\n+      List<String> protocolsWhitelist}) async {","path":"lib/src/web_socket/browser/sockjs.dart","position":32,"original_position":32,"commit_id":"c45a439dc953e6e3c42bb644879fa151b21f89aa","original_commit_id":"c45a439dc953e6e3c42bb644879fa151b21f89aa","user":{"login":"trentgrover-wf","id":3778206,"avatar_url":"https://avatars.githubusercontent.com/u/3778206?v=3","gravatar_id":"","url":"https://api.github.com/users/trentgrover-wf","html_url":"https://github.com/trentgrover-wf","followers_url":"https://api.github.com/users/trentgrover-wf/followers","following_url":"https://api.github.com/users/trentgrover-wf/following{/other_user}","gists_url":"https://api.github.com/users/trentgrover-wf/gists{/gist_id}","starred_url":"https://api.github.com/users/trentgrover-wf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/trentgrover-wf/subscriptions","organizations_url":"https://api.github.com/users/trentgrover-wf/orgs","repos_url":"https://api.github.com/users/trentgrover-wf/repos","events_url":"https://api.github.com/users/trentgrover-wf/events{/privacy}","received_events_url":"https://api.github.com/users/trentgrover-wf/received_events","type":"User","site_admin":false},"body":"default to empty list or is null OK down the chain?","created_at":"2015-11-11T17:48:08Z","updated_at":"2015-11-11T17:48:08Z","html_url":"https://github.com/Workiva/w_transport/pull/74#discussion_r44562064","pull_request_url":"https://api.github.com/repos/Workiva/w_transport/pulls/74","_links":{"self":{"href":"https://api.github.com/repos/Workiva/w_transport/pulls/comments/44562064"},"html":{"href":"https://github.com/Workiva/w_transport/pull/74#discussion_r44562064"},"pull_request":{"href":"https://api.github.com/repos/Workiva/w_transport/pulls/74"}}},"pull_request":{"url":"https://api.github.com/repos/Workiva/w_transport/pulls/74","id":50303504,"html_url":"https://github.com/Workiva/w_transport/pull/74","diff_url":"https://github.com/Workiva/w_transport/pull/74.diff","patch_url":"https://github.com/Workiva/w_transport/pull/74.patch","issue_url":"https://api.github.com/repos/Workiva/w_transport/issues/74","number":74,"state":"open","locked":false,"title":"Support usage of SockJS.","user":{"login":"evanweible-wf","id":1738457,"avatar_url":"https://avatars.githubusercontent.com/u/1738457?v=3","gravatar_id":"","url":"https://api.github.com/users/evanweible-wf","html_url":"https://github.com/evanweible-wf","followers_url":"https://api.github.com/users/evanweible-wf/followers","following_url":"https://api.github.com/users/evanweible-wf/following{/other_user}","gists_url":"https://api.github.com/users/evanweible-wf/gists{/gist_id}","starred_url":"https://api.github.com/users/evanweible-wf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/evanweible-wf/subscriptions","organizations_url":"https://api.github.com/users/evanweible-wf/orgs","repos_url":"https://api.github.com/users/evanweible-wf/repos","events_url":"https://api.github.com/users/evanweible-wf/events{/privacy}","received_events_url":"https://api.github.com/users/evanweible-wf/received_events","type":"User","site_admin":false},"body":"Addresses #68.\r\n\r\n## Issue\r\n- Not all browsers support native WebSockets. SockJS provides the ability to fallback to XHR-streaming if this is the case, but currently w_transport is not compatible with SockJS.\r\n\r\n## Changes\r\n**Source:**\r\n- Add an additional implementation of the `WSocket` class that utilizes [SockJS client](https://github.com/Workiva/sockjs-dart-client) instead of the native `WebSocket` class directly.\r\n  - This is almost identical to the browser implementation (in fact I may try to merge some of the common code)\r\n- Add optional parameters to the `configureWTransportForBrowser()` method for enabling SockJS.\r\n\r\nTo use SockJS in the browser:\r\n```dart\r\nimport 'package:w_transport/w_transport.dart';\r\nimport 'package:w_transport/w_transport_browser.dart';\r\n\r\nmain() async {\r\n  configureWTransportForBrowser(useSockJS: true, sockJSProtocolsWhitelist: ['websocket', 'xhr-streaming']);\r\n  WSocket socket = await WSocket.connect(Uri.parse('ws://localhost:8000/path/to/sockjs/server'));\r\n}\r\n```\r\n\r\n**Tests:**\r\n- New SockJS integration server added that runs during tests/coverage\r\n- Integration tests added to test \r\n\r\n## Areas of Regression\r\n- n/a\r\n\r\n## TODO\r\n- [x] ~~Combine common code from the browser implementation and the SockJS implementation~~ The amount of common code here is small enough that I'm going to leave it. It would be overkill to create another super class just for a few lines of common code.\r\n- [x] Apply common unit test suite for `WSocket` to the two SockJS configurations (websocket and xhr-streaming)\r\n- [x] Fix coverage (currently fails on SockJS's XHR-streaming configuration because the origin header is null in content-shell)\r\n- [ ] Make the sockjs-dart-client lib public\r\n\r\n## Testing\r\n- CI passes\r\n\r\n## Code Review\r\n@trentgrover-wf\r\n@maxwellpeterson-wf \r\n@dustinlessard-wf\r\n@jayudey-wf \r\n\r\nfyi: @stevenosborne-wf @tylertreat-wf ","created_at":"2015-11-10T20:03:03Z","updated_at":"2015-11-11T17:48:08Z","closed_at":null,"merged_at":null,"merge_commit_sha":"5d30981d7f6a4a23becd89a1fda5bdb21c0ab0c9","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/Workiva/w_transport/pulls/74/commits","review_comments_url":"https://api.github.com/repos/Workiva/w_transport/pulls/74/comments","review_comment_url":"https://api.github.com/repos/Workiva/w_transport/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Workiva/w_transport/issues/74/comments","statuses_url":"https://api.github.com/repos/Workiva/w_transport/statuses/c45a439dc953e6e3c42bb644879fa151b21f89aa","head":{"label":"Workiva:sockjs","ref":"sockjs","sha":"c45a439dc953e6e3c42bb644879fa151b21f89aa","user":{"login":"Workiva","id":1087529,"avatar_url":"https://avatars.githubusercontent.com/u/1087529?v=3","gravatar_id":"","url":"https://api.github.com/users/Workiva","html_url":"https://github.com/Workiva","followers_url":"https://api.github.com/users/Workiva/followers","following_url":"https://api.github.com/users/Workiva/following{/other_user}","gists_url":"https://api.github.com/users/Workiva/gists{/gist_id}","starred_url":"https://api.github.com/users/Workiva/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Workiva/subscriptions","organizations_url":"https://api.github.com/users/Workiva/orgs","repos_url":"https://api.github.com/users/Workiva/repos","events_url":"https://api.github.com/users/Workiva/events{/privacy}","received_events_url":"https://api.github.com/users/Workiva/received_events","type":"Organization","site_admin":false},"repo":{"id":32808289,"name":"w_transport","full_name":"Workiva/w_transport","owner":{"login":"Workiva","id":1087529,"avatar_url":"https://avatars.githubusercontent.com/u/1087529?v=3","gravatar_id":"","url":"https://api.github.com/users/Workiva","html_url":"https://github.com/Workiva","followers_url":"https://api.github.com/users/Workiva/followers","following_url":"https://api.github.com/users/Workiva/following{/other_user}","gists_url":"https://api.github.com/users/Workiva/gists{/gist_id}","starred_url":"https://api.github.com/users/Workiva/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Workiva/subscriptions","organizations_url":"https://api.github.com/users/Workiva/orgs","repos_url":"https://api.github.com/users/Workiva/repos","events_url":"https://api.github.com/users/Workiva/events{/privacy}","received_events_url":"https://api.github.com/users/Workiva/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Workiva/w_transport","description":"","fork":false,"url":"https://api.github.com/repos/Workiva/w_transport","forks_url":"https://api.github.com/repos/Workiva/w_transport/forks","keys_url":"https://api.github.com/repos/Workiva/w_transport/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Workiva/w_transport/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Workiva/w_transport/teams","hooks_url":"https://api.github.com/repos/Workiva/w_transport/hooks","issue_events_url":"https://api.github.com/repos/Workiva/w_transport/issues/events{/number}","events_url":"https://api.github.com/repos/Workiva/w_transport/events","assignees_url":"https://api.github.com/repos/Workiva/w_transport/assignees{/user}","branches_url":"https://api.github.com/repos/Workiva/w_transport/branches{/branch}","tags_url":"https://api.github.com/repos/Workiva/w_transport/tags","blobs_url":"https://api.github.com/repos/Workiva/w_transport/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Workiva/w_transport/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Workiva/w_transport/git/refs{/sha}","trees_url":"https://api.github.com/repos/Workiva/w_transport/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Workiva/w_transport/statuses/{sha}","languages_url":"https://api.github.com/repos/Workiva/w_transport/languages","stargazers_url":"https://api.github.com/repos/Workiva/w_transport/stargazers","contributors_url":"https://api.github.com/repos/Workiva/w_transport/contributors","subscribers_url":"https://api.github.com/repos/Workiva/w_transport/subscribers","subscription_url":"https://api.github.com/repos/Workiva/w_transport/subscription","commits_url":"https://api.github.com/repos/Workiva/w_transport/commits{/sha}","git_commits_url":"https://api.github.com/repos/Workiva/w_transport/git/commits{/sha}","comments_url":"https://api.github.com/repos/Workiva/w_transport/comments{/number}","issue_comment_url":"https://api.github.com/repos/Workiva/w_transport/issues/comments{/number}","contents_url":"https://api.github.com/repos/Workiva/w_transport/contents/{+path}","compare_url":"https://api.github.com/repos/Workiva/w_transport/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Workiva/w_transport/merges","archive_url":"https://api.github.com/repos/Workiva/w_transport/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Workiva/w_transport/downloads","issues_url":"https://api.github.com/repos/Workiva/w_transport/issues{/number}","pulls_url":"https://api.github.com/repos/Workiva/w_transport/pulls{/number}","milestones_url":"https://api.github.com/repos/Workiva/w_transport/milestones{/number}","notifications_url":"https://api.github.com/repos/Workiva/w_transport/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Workiva/w_transport/labels{/name}","releases_url":"https://api.github.com/repos/Workiva/w_transport/releases{/id}","created_at":"2015-03-24T15:43:40Z","updated_at":"2015-09-10T12:24:41Z","pushed_at":"2015-11-11T17:27:23Z","git_url":"git://github.com/Workiva/w_transport.git","ssh_url":"git@github.com:Workiva/w_transport.git","clone_url":"https://github.com/Workiva/w_transport.git","svn_url":"https://github.com/Workiva/w_transport","homepage":null,"size":1134,"stargazers_count":3,"watchers_count":3,"language":"Dart","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":6,"forks":1,"open_issues":6,"watchers":3,"default_branch":"master"}},"base":{"label":"Workiva:master","ref":"master","sha":"8fb4dde18f8c14ee62e98fcccab51f1adb67388f","user":{"login":"Workiva","id":1087529,"avatar_url":"https://avatars.githubusercontent.com/u/1087529?v=3","gravatar_id":"","url":"https://api.github.com/users/Workiva","html_url":"https://github.com/Workiva","followers_url":"https://api.github.com/users/Workiva/followers","following_url":"https://api.github.com/users/Workiva/following{/other_user}","gists_url":"https://api.github.com/users/Workiva/gists{/gist_id}","starred_url":"https://api.github.com/users/Workiva/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Workiva/subscriptions","organizations_url":"https://api.github.com/users/Workiva/orgs","repos_url":"https://api.github.com/users/Workiva/repos","events_url":"https://api.github.com/users/Workiva/events{/privacy}","received_events_url":"https://api.github.com/users/Workiva/received_events","type":"Organization","site_admin":false},"repo":{"id":32808289,"name":"w_transport","full_name":"Workiva/w_transport","owner":{"login":"Workiva","id":1087529,"avatar_url":"https://avatars.githubusercontent.com/u/1087529?v=3","gravatar_id":"","url":"https://api.github.com/users/Workiva","html_url":"https://github.com/Workiva","followers_url":"https://api.github.com/users/Workiva/followers","following_url":"https://api.github.com/users/Workiva/following{/other_user}","gists_url":"https://api.github.com/users/Workiva/gists{/gist_id}","starred_url":"https://api.github.com/users/Workiva/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Workiva/subscriptions","organizations_url":"https://api.github.com/users/Workiva/orgs","repos_url":"https://api.github.com/users/Workiva/repos","events_url":"https://api.github.com/users/Workiva/events{/privacy}","received_events_url":"https://api.github.com/users/Workiva/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Workiva/w_transport","description":"","fork":false,"url":"https://api.github.com/repos/Workiva/w_transport","forks_url":"https://api.github.com/repos/Workiva/w_transport/forks","keys_url":"https://api.github.com/repos/Workiva/w_transport/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Workiva/w_transport/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Workiva/w_transport/teams","hooks_url":"https://api.github.com/repos/Workiva/w_transport/hooks","issue_events_url":"https://api.github.com/repos/Workiva/w_transport/issues/events{/number}","events_url":"https://api.github.com/repos/Workiva/w_transport/events","assignees_url":"https://api.github.com/repos/Workiva/w_transport/assignees{/user}","branches_url":"https://api.github.com/repos/Workiva/w_transport/branches{/branch}","tags_url":"https://api.github.com/repos/Workiva/w_transport/tags","blobs_url":"https://api.github.com/repos/Workiva/w_transport/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Workiva/w_transport/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Workiva/w_transport/git/refs{/sha}","trees_url":"https://api.github.com/repos/Workiva/w_transport/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Workiva/w_transport/statuses/{sha}","languages_url":"https://api.github.com/repos/Workiva/w_transport/languages","stargazers_url":"https://api.github.com/repos/Workiva/w_transport/stargazers","contributors_url":"https://api.github.com/repos/Workiva/w_transport/contributors","subscribers_url":"https://api.github.com/repos/Workiva/w_transport/subscribers","subscription_url":"https://api.github.com/repos/Workiva/w_transport/subscription","commits_url":"https://api.github.com/repos/Workiva/w_transport/commits{/sha}","git_commits_url":"https://api.github.com/repos/Workiva/w_transport/git/commits{/sha}","comments_url":"https://api.github.com/repos/Workiva/w_transport/comments{/number}","issue_comment_url":"https://api.github.com/repos/Workiva/w_transport/issues/comments{/number}","contents_url":"https://api.github.com/repos/Workiva/w_transport/contents/{+path}","compare_url":"https://api.github.com/repos/Workiva/w_transport/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Workiva/w_transport/merges","archive_url":"https://api.github.com/repos/Workiva/w_transport/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Workiva/w_transport/downloads","issues_url":"https://api.github.com/repos/Workiva/w_transport/issues{/number}","pulls_url":"https://api.github.com/repos/Workiva/w_transport/pulls{/number}","milestones_url":"https://api.github.com/repos/Workiva/w_transport/milestones{/number}","notifications_url":"https://api.github.com/repos/Workiva/w_transport/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Workiva/w_transport/labels{/name}","releases_url":"https://api.github.com/repos/Workiva/w_transport/releases{/id}","created_at":"2015-03-24T15:43:40Z","updated_at":"2015-09-10T12:24:41Z","pushed_at":"2015-11-11T17:27:23Z","git_url":"git://github.com/Workiva/w_transport.git","ssh_url":"git@github.com:Workiva/w_transport.git","clone_url":"https://github.com/Workiva/w_transport.git","svn_url":"https://github.com/Workiva/w_transport","homepage":null,"size":1134,"stargazers_count":3,"watchers_count":3,"language":"Dart","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":6,"forks":1,"open_issues":6,"watchers":3,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Workiva/w_transport/pulls/74"},"html":{"href":"https://github.com/Workiva/w_transport/pull/74"},"issue":{"href":"https://api.github.com/repos/Workiva/w_transport/issues/74"},"comments":{"href":"https://api.github.com/repos/Workiva/w_transport/issues/74/comments"},"review_comments":{"href":"https://api.github.com/repos/Workiva/w_transport/pulls/74/comments"},"review_comment":{"href":"https://api.github.com/repos/Workiva/w_transport/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Workiva/w_transport/pulls/74/commits"},"statuses":{"href":"https://api.github.com/repos/Workiva/w_transport/statuses/c45a439dc953e6e3c42bb644879fa151b21f89aa"}}}}