| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 final String _webSocketGUID = "258EAFA5-E914-47DA-95CA-C5AB0DC85B11"; | 5 final String _webSocketGUID = "258EAFA5-E914-47DA-95CA-C5AB0DC85B11"; |
| 6 | 6 |
| 7 class _WebSocketMessageType { | 7 class _WebSocketMessageType { |
| 8 static final int NONE = 0; | 8 static final int NONE = 0; |
| 9 static final int BINARY = 1; | 9 static final int BINARY = 1; |
| 10 static final int TEXT = 2; | 10 static final int TEXT = 2; |
| (...skipping 815 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 826 } | 826 } |
| 827 }; | 827 }; |
| 828 _wsconn.onNoUpgrade = (response) { | 828 _wsconn.onNoUpgrade = (response) { |
| 829 if (_onerror != null) _onerror("Failed web socket connection"); | 829 if (_onerror != null) _onerror("Failed web socket connection"); |
| 830 }; | 830 }; |
| 831 _wsconn.onError = (e) { | 831 _wsconn.onError = (e) { |
| 832 if (_onerror != null) _onerror(e); | 832 if (_onerror != null) _onerror(e); |
| 833 }; | 833 }; |
| 834 } | 834 } |
| 835 | 835 |
| 836 int get readyState() => _readyState; | 836 int get readyState => _readyState; |
| 837 int get bufferedAmount() => 0; | 837 int get bufferedAmount => 0; |
| 838 | 838 |
| 839 void set onopen(Function callback) { | 839 void set onopen(Function callback) { |
| 840 _onopen = callback; | 840 _onopen = callback; |
| 841 } | 841 } |
| 842 | 842 |
| 843 void set onerror(Function callback) { | 843 void set onerror(Function callback) { |
| 844 _onerror = callback; | 844 _onerror = callback; |
| 845 } | 845 } |
| 846 | 846 |
| 847 void set onclose(Function callback) { | 847 void set onclose(Function callback) { |
| 848 _onclose = callback; | 848 _onclose = callback; |
| 849 } | 849 } |
| 850 | 850 |
| 851 String get extensions() => null; | 851 String get extensions => null; |
| 852 String get protocol() => null; | 852 String get protocol => null; |
| 853 | 853 |
| 854 void close(int code, String reason) { | 854 void close(int code, String reason) { |
| 855 if (_readyState < WebSocket.CLOSING) _readyState = WebSocket.CLOSING; | 855 if (_readyState < WebSocket.CLOSING) _readyState = WebSocket.CLOSING; |
| 856 _wsconn.close(code, reason); | 856 _wsconn.close(code, reason); |
| 857 } | 857 } |
| 858 | 858 |
| 859 void set onmessage(Function callback) { | 859 void set onmessage(Function callback) { |
| 860 _onmessage = callback; | 860 _onmessage = callback; |
| 861 } | 861 } |
| 862 | 862 |
| 863 void send(data) { | 863 void send(data) { |
| 864 _wsconn.send(data); | 864 _wsconn.send(data); |
| 865 } | 865 } |
| 866 | 866 |
| 867 WebSocketClientConnection _wsconn; | 867 WebSocketClientConnection _wsconn; |
| 868 int _readyState = WebSocket.CONNECTING; | 868 int _readyState = WebSocket.CONNECTING; |
| 869 Function _onopen; | 869 Function _onopen; |
| 870 Function _onerror; | 870 Function _onerror; |
| 871 Function _onclose; | 871 Function _onclose; |
| 872 Function _onmessage; | 872 Function _onmessage; |
| 873 } | 873 } |
| 874 | 874 |
| 875 | 875 |
| 876 class _WebSocketMessageEvent implements MessageEvent { | 876 class _WebSocketMessageEvent implements MessageEvent { |
| 877 _WebSocketMessageEvent(this._data); | 877 _WebSocketMessageEvent(this._data); |
| 878 get data() => _data; | 878 get data => _data; |
| 879 var _data; | 879 var _data; |
| 880 } | 880 } |
| 881 | 881 |
| 882 | 882 |
| 883 class _WebSocketCloseEvent implements CloseEvent { | 883 class _WebSocketCloseEvent implements CloseEvent { |
| 884 _WebSocketCloseEvent(this._wasClean, this._code, this._reason); | 884 _WebSocketCloseEvent(this._wasClean, this._code, this._reason); |
| 885 bool get wasClean() => _wasClean; | 885 bool get wasClean => _wasClean; |
| 886 int get code() => _code; | 886 int get code => _code; |
| 887 String get reason() => _reason; | 887 String get reason => _reason; |
| 888 bool _wasClean; | 888 bool _wasClean; |
| 889 int _code; | 889 int _code; |
| 890 String _reason; | 890 String _reason; |
| 891 } | 891 } |
| OLD | NEW |