{"action":"created","comment":{"url":"https://api.github.com/repos/markerickson-wf/thrift/pulls/comments/39424976","id":39424976,"diff_hunk":"@@ -0,0 +1,130 @@\n+/// Licensed to the Apache Software Foundation (ASF) under one\n+/// or more contributor license agreements. See the NOTICE file\n+/// distributed with this work for additional information\n+/// regarding copyright ownership. The ASF licenses this file\n+/// to you under the Apache License, Version 2.0 (the\n+/// \"License\"); you may not use this file except in compliance\n+/// with the License. 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,\n+/// software distributed under the License is distributed on an\n+/// \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n+/// KIND, either express or implied. See the License for the\n+/// specific language governing permissions and limitations\n+/// under the License.\n+\n+library thrift.src.browser;\n+\n+import 'dart:async';\n+import 'dart:html' show CloseEvent;\n+import 'dart:html' show Event;\n+import 'dart:html' show MessageEvent;\n+import 'dart:html' show WebSocket;\n+import 'dart:typed_data' show Uint8List;\n+\n+import 'package:crypto/crypto.dart' show CryptoUtils;\n+import 'package:thrift/thrift.dart';\n+\n+/// A [TSocket] backed by a [WebSocket] from dart:html\n+class TWebSocket implements TSocket {\n+  final Uri url;\n+\n+  final StreamController<TSocketState> _onStateController;\n+  Stream<TSocketState> get onState => _onStateController.stream;\n+\n+  final StreamController<Object> _onErrorController;\n+  Stream<Object> get onError => _onErrorController.stream;\n+\n+  final StreamController<Uint8List> _onMessageController;\n+  Stream<Uint8List> get onMessage => _onMessageController.stream;\n+\n+  final List<Uint8List> _requests = [];\n+\n+  TWebSocket(this.url)\n+      : _onStateController = new StreamController.broadcast(),\n+        _onErrorController = new StreamController.broadcast(),\n+        _onMessageController = new StreamController.broadcast() {\n+    if (url == null || !url.hasAuthority || !url.hasPort) {\n+      throw new ArgumentError('Invalid url');\n+    }\n+  }\n+\n+  WebSocket _socket;\n+\n+  bool get isOpen => _socket != null && _socket.readyState == WebSocket.OPEN;\n+\n+  bool get isClosed =>\n+      _socket == null || _socket.readyState == WebSocket.CLOSED;\n+\n+  Future open() {\n+    if (!isClosed) {\n+      throw new TTransportError(\n+          TTransportErrorType.ALREADY_OPEN, 'Socket already connected');\n+    }\n+\n+    _socket = new WebSocket(url.toString());\n+    _socket.onError.listen(_onError);\n+    _socket.onOpen.listen(_onOpen);\n+    _socket.onClose.listen(_onClose);\n+    _socket.onMessage.listen(_onMessage);\n+\n+    return _socket.onOpen.first;","path":"lib/dart/lib/src/browser/t_web_socket.dart","position":73,"original_position":73,"commit_id":"7bacb040c0cde5f35c9ec0ea3135d0ed1d79eae0","original_commit_id":"7bacb040c0cde5f35c9ec0ea3135d0ed1d79eae0","user":{"login":"markerickson-wf","id":1444693,"avatar_url":"https://avatars.githubusercontent.com/u/1444693?v=3","gravatar_id":"","url":"https://api.github.com/users/markerickson-wf","html_url":"https://github.com/markerickson-wf","followers_url":"https://api.github.com/users/markerickson-wf/followers","following_url":"https://api.github.com/users/markerickson-wf/following{/other_user}","gists_url":"https://api.github.com/users/markerickson-wf/gists{/gist_id}","starred_url":"https://api.github.com/users/markerickson-wf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/markerickson-wf/subscriptions","organizations_url":"https://api.github.com/users/markerickson-wf/orgs","repos_url":"https://api.github.com/users/markerickson-wf/repos","events_url":"https://api.github.com/users/markerickson-wf/events{/privacy}","received_events_url":"https://api.github.com/users/markerickson-wf/received_events","type":"User","site_admin":false},"body":"`onOpen` for an html `WebSocket` returns an `EventStreamProvider.forTarget`, which is documented to return a broadcast stream.\r\n\r\n","created_at":"2015-09-14T17:57:16Z","updated_at":"2015-09-14T17:57:16Z","html_url":"https://github.com/markerickson-wf/thrift/pull/1#discussion_r39424976","pull_request_url":"https://api.github.com/repos/markerickson-wf/thrift/pulls/1","_links":{"self":{"href":"https://api.github.com/repos/markerickson-wf/thrift/pulls/comments/39424976"},"html":{"href":"https://github.com/markerickson-wf/thrift/pull/1#discussion_r39424976"},"pull_request":{"href":"https://api.github.com/repos/markerickson-wf/thrift/pulls/1"}}},"pull_request":{"url":"https://api.github.com/repos/markerickson-wf/thrift/pulls/1","id":44742812,"html_url":"https://github.com/markerickson-wf/thrift/pull/1","diff_url":"https://github.com/markerickson-wf/thrift/pull/1.diff","patch_url":"https://github.com/markerickson-wf/thrift/pull/1.patch","issue_url":"https://api.github.com/repos/markerickson-wf/thrift/issues/1","number":1,"state":"open","locked":false,"title":"Apache Thrift language binding for Dart","user":{"login":"markerickson-wf","id":1444693,"avatar_url":"https://avatars.githubusercontent.com/u/1444693?v=3","gravatar_id":"","url":"https://api.github.com/users/markerickson-wf","html_url":"https://github.com/markerickson-wf","followers_url":"https://api.github.com/users/markerickson-wf/followers","following_url":"https://api.github.com/users/markerickson-wf/following{/other_user}","gists_url":"https://api.github.com/users/markerickson-wf/gists{/gist_id}","starred_url":"https://api.github.com/users/markerickson-wf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/markerickson-wf/subscriptions","organizations_url":"https://api.github.com/users/markerickson-wf/orgs","repos_url":"https://api.github.com/users/markerickson-wf/repos","events_url":"https://api.github.com/users/markerickson-wf/events{/privacy}","received_events_url":"https://api.github.com/users/markerickson-wf/received_events","type":"User","site_admin":false},"body":"IN PROGRESS\r\n\r\nCreate an Apache Thrift language binding for Dart (dartlang.org).\r\nhttps://issues.apache.org/jira/browse/THRIFT-3299\r\n\r\nCurrently basic functionality is implemented and the tutorial is working.  Integration tests will be written before a PR to Apache is made.","created_at":"2015-09-11T03:17:46Z","updated_at":"2015-09-14T17:57:16Z","closed_at":null,"merged_at":null,"merge_commit_sha":"3492804ababed164cc6f7afbf5f8cb79de6663c6","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/markerickson-wf/thrift/pulls/1/commits","review_comments_url":"https://api.github.com/repos/markerickson-wf/thrift/pulls/1/comments","review_comment_url":"https://api.github.com/repos/markerickson-wf/thrift/pulls/comments{/number}","comments_url":"https://api.github.com/repos/markerickson-wf/thrift/issues/1/comments","statuses_url":"https://api.github.com/repos/markerickson-wf/thrift/statuses/7bacb040c0cde5f35c9ec0ea3135d0ed1d79eae0","head":{"label":"markerickson-wf:thrift-dart","ref":"thrift-dart","sha":"7bacb040c0cde5f35c9ec0ea3135d0ed1d79eae0","user":{"login":"markerickson-wf","id":1444693,"avatar_url":"https://avatars.githubusercontent.com/u/1444693?v=3","gravatar_id":"","url":"https://api.github.com/users/markerickson-wf","html_url":"https://github.com/markerickson-wf","followers_url":"https://api.github.com/users/markerickson-wf/followers","following_url":"https://api.github.com/users/markerickson-wf/following{/other_user}","gists_url":"https://api.github.com/users/markerickson-wf/gists{/gist_id}","starred_url":"https://api.github.com/users/markerickson-wf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/markerickson-wf/subscriptions","organizations_url":"https://api.github.com/users/markerickson-wf/orgs","repos_url":"https://api.github.com/users/markerickson-wf/repos","events_url":"https://api.github.com/users/markerickson-wf/events{/privacy}","received_events_url":"https://api.github.com/users/markerickson-wf/received_events","type":"User","site_admin":false},"repo":{"id":41041232,"name":"thrift","full_name":"markerickson-wf/thrift","owner":{"login":"markerickson-wf","id":1444693,"avatar_url":"https://avatars.githubusercontent.com/u/1444693?v=3","gravatar_id":"","url":"https://api.github.com/users/markerickson-wf","html_url":"https://github.com/markerickson-wf","followers_url":"https://api.github.com/users/markerickson-wf/followers","following_url":"https://api.github.com/users/markerickson-wf/following{/other_user}","gists_url":"https://api.github.com/users/markerickson-wf/gists{/gist_id}","starred_url":"https://api.github.com/users/markerickson-wf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/markerickson-wf/subscriptions","organizations_url":"https://api.github.com/users/markerickson-wf/orgs","repos_url":"https://api.github.com/users/markerickson-wf/repos","events_url":"https://api.github.com/users/markerickson-wf/events{/privacy}","received_events_url":"https://api.github.com/users/markerickson-wf/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/markerickson-wf/thrift","description":"Mirror of Apache Thrift","fork":true,"url":"https://api.github.com/repos/markerickson-wf/thrift","forks_url":"https://api.github.com/repos/markerickson-wf/thrift/forks","keys_url":"https://api.github.com/repos/markerickson-wf/thrift/keys{/key_id}","collaborators_url":"https://api.github.com/repos/markerickson-wf/thrift/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/markerickson-wf/thrift/teams","hooks_url":"https://api.github.com/repos/markerickson-wf/thrift/hooks","issue_events_url":"https://api.github.com/repos/markerickson-wf/thrift/issues/events{/number}","events_url":"https://api.github.com/repos/markerickson-wf/thrift/events","assignees_url":"https://api.github.com/repos/markerickson-wf/thrift/assignees{/user}","branches_url":"https://api.github.com/repos/markerickson-wf/thrift/branches{/branch}","tags_url":"https://api.github.com/repos/markerickson-wf/thrift/tags","blobs_url":"https://api.github.com/repos/markerickson-wf/thrift/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/markerickson-wf/thrift/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/markerickson-wf/thrift/git/refs{/sha}","trees_url":"https://api.github.com/repos/markerickson-wf/thrift/git/trees{/sha}","statuses_url":"https://api.github.com/repos/markerickson-wf/thrift/statuses/{sha}","languages_url":"https://api.github.com/repos/markerickson-wf/thrift/languages","stargazers_url":"https://api.github.com/repos/markerickson-wf/thrift/stargazers","contributors_url":"https://api.github.com/repos/markerickson-wf/thrift/contributors","subscribers_url":"https://api.github.com/repos/markerickson-wf/thrift/subscribers","subscription_url":"https://api.github.com/repos/markerickson-wf/thrift/subscription","commits_url":"https://api.github.com/repos/markerickson-wf/thrift/commits{/sha}","git_commits_url":"https://api.github.com/repos/markerickson-wf/thrift/git/commits{/sha}","comments_url":"https://api.github.com/repos/markerickson-wf/thrift/comments{/number}","issue_comment_url":"https://api.github.com/repos/markerickson-wf/thrift/issues/comments{/number}","contents_url":"https://api.github.com/repos/markerickson-wf/thrift/contents/{+path}","compare_url":"https://api.github.com/repos/markerickson-wf/thrift/compare/{base}...{head}","merges_url":"https://api.github.com/repos/markerickson-wf/thrift/merges","archive_url":"https://api.github.com/repos/markerickson-wf/thrift/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/markerickson-wf/thrift/downloads","issues_url":"https://api.github.com/repos/markerickson-wf/thrift/issues{/number}","pulls_url":"https://api.github.com/repos/markerickson-wf/thrift/pulls{/number}","milestones_url":"https://api.github.com/repos/markerickson-wf/thrift/milestones{/number}","notifications_url":"https://api.github.com/repos/markerickson-wf/thrift/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/markerickson-wf/thrift/labels{/name}","releases_url":"https://api.github.com/repos/markerickson-wf/thrift/releases{/id}","created_at":"2015-08-19T15:01:41Z","updated_at":"2015-08-19T15:01:46Z","pushed_at":"2015-09-14T17:34:22Z","git_url":"git://github.com/markerickson-wf/thrift.git","ssh_url":"git@github.com:markerickson-wf/thrift.git","clone_url":"https://github.com/markerickson-wf/thrift.git","svn_url":"https://github.com/markerickson-wf/thrift","homepage":"","size":13477,"stargazers_count":0,"watchers_count":0,"language":"C++","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"markerickson-wf:master","ref":"master","sha":"34e0bb64bda3f7163e715fab09d014696deefa9c","user":{"login":"markerickson-wf","id":1444693,"avatar_url":"https://avatars.githubusercontent.com/u/1444693?v=3","gravatar_id":"","url":"https://api.github.com/users/markerickson-wf","html_url":"https://github.com/markerickson-wf","followers_url":"https://api.github.com/users/markerickson-wf/followers","following_url":"https://api.github.com/users/markerickson-wf/following{/other_user}","gists_url":"https://api.github.com/users/markerickson-wf/gists{/gist_id}","starred_url":"https://api.github.com/users/markerickson-wf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/markerickson-wf/subscriptions","organizations_url":"https://api.github.com/users/markerickson-wf/orgs","repos_url":"https://api.github.com/users/markerickson-wf/repos","events_url":"https://api.github.com/users/markerickson-wf/events{/privacy}","received_events_url":"https://api.github.com/users/markerickson-wf/received_events","type":"User","site_admin":false},"repo":{"id":41041232,"name":"thrift","full_name":"markerickson-wf/thrift","owner":{"login":"markerickson-wf","id":1444693,"avatar_url":"https://avatars.githubusercontent.com/u/1444693?v=3","gravatar_id":"","url":"https://api.github.com/users/markerickson-wf","html_url":"https://github.com/markerickson-wf","followers_url":"https://api.github.com/users/markerickson-wf/followers","following_url":"https://api.github.com/users/markerickson-wf/following{/other_user}","gists_url":"https://api.github.com/users/markerickson-wf/gists{/gist_id}","starred_url":"https://api.github.com/users/markerickson-wf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/markerickson-wf/subscriptions","organizations_url":"https://api.github.com/users/markerickson-wf/orgs","repos_url":"https://api.github.com/users/markerickson-wf/repos","events_url":"https://api.github.com/users/markerickson-wf/events{/privacy}","received_events_url":"https://api.github.com/users/markerickson-wf/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/markerickson-wf/thrift","description":"Mirror of Apache Thrift","fork":true,"url":"https://api.github.com/repos/markerickson-wf/thrift","forks_url":"https://api.github.com/repos/markerickson-wf/thrift/forks","keys_url":"https://api.github.com/repos/markerickson-wf/thrift/keys{/key_id}","collaborators_url":"https://api.github.com/repos/markerickson-wf/thrift/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/markerickson-wf/thrift/teams","hooks_url":"https://api.github.com/repos/markerickson-wf/thrift/hooks","issue_events_url":"https://api.github.com/repos/markerickson-wf/thrift/issues/events{/number}","events_url":"https://api.github.com/repos/markerickson-wf/thrift/events","assignees_url":"https://api.github.com/repos/markerickson-wf/thrift/assignees{/user}","branches_url":"https://api.github.com/repos/markerickson-wf/thrift/branches{/branch}","tags_url":"https://api.github.com/repos/markerickson-wf/thrift/tags","blobs_url":"https://api.github.com/repos/markerickson-wf/thrift/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/markerickson-wf/thrift/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/markerickson-wf/thrift/git/refs{/sha}","trees_url":"https://api.github.com/repos/markerickson-wf/thrift/git/trees{/sha}","statuses_url":"https://api.github.com/repos/markerickson-wf/thrift/statuses/{sha}","languages_url":"https://api.github.com/repos/markerickson-wf/thrift/languages","stargazers_url":"https://api.github.com/repos/markerickson-wf/thrift/stargazers","contributors_url":"https://api.github.com/repos/markerickson-wf/thrift/contributors","subscribers_url":"https://api.github.com/repos/markerickson-wf/thrift/subscribers","subscription_url":"https://api.github.com/repos/markerickson-wf/thrift/subscription","commits_url":"https://api.github.com/repos/markerickson-wf/thrift/commits{/sha}","git_commits_url":"https://api.github.com/repos/markerickson-wf/thrift/git/commits{/sha}","comments_url":"https://api.github.com/repos/markerickson-wf/thrift/comments{/number}","issue_comment_url":"https://api.github.com/repos/markerickson-wf/thrift/issues/comments{/number}","contents_url":"https://api.github.com/repos/markerickson-wf/thrift/contents/{+path}","compare_url":"https://api.github.com/repos/markerickson-wf/thrift/compare/{base}...{head}","merges_url":"https://api.github.com/repos/markerickson-wf/thrift/merges","archive_url":"https://api.github.com/repos/markerickson-wf/thrift/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/markerickson-wf/thrift/downloads","issues_url":"https://api.github.com/repos/markerickson-wf/thrift/issues{/number}","pulls_url":"https://api.github.com/repos/markerickson-wf/thrift/pulls{/number}","milestones_url":"https://api.github.com/repos/markerickson-wf/thrift/milestones{/number}","notifications_url":"https://api.github.com/repos/markerickson-wf/thrift/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/markerickson-wf/thrift/labels{/name}","releases_url":"https://api.github.com/repos/markerickson-wf/thrift/releases{/id}","created_at":"2015-08-19T15:01:41Z","updated_at":"2015-08-19T15:01:46Z","pushed_at":"2015-09-14T17:34:22Z","git_url":"git://github.com/markerickson-wf/thrift.git","ssh_url":"git@github.com:markerickson-wf/thrift.git","clone_url":"https://github.com/markerickson-wf/thrift.git","svn_url":"https://github.com/markerickson-wf/thrift","homepage":"","size":13477,"stargazers_count":0,"watchers_count":0,"language":"C++","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/markerickson-wf/thrift/pulls/1"},"html":{"href":"https://github.com/markerickson-wf/thrift/pull/1"},"issue":{"href":"https://api.github.com/repos/markerickson-wf/thrift/issues/1"},"comments":{"href":"https://api.github.com/repos/markerickson-wf/thrift/issues/1/comments"},"review_comments":{"href":"https://api.github.com/repos/markerickson-wf/thrift/pulls/1/comments"},"review_comment":{"href":"https://api.github.com/repos/markerickson-wf/thrift/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/markerickson-wf/thrift/pulls/1/commits"},"statuses":{"href":"https://api.github.com/repos/markerickson-wf/thrift/statuses/7bacb040c0cde5f35c9ec0ea3135d0ed1d79eae0"}}}}