| 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 const String _webSocketGUID = "258EAFA5-E914-47DA-95CA-C5AB0DC85B11"; |
| 6 | 6 |
| 7 class _WebSocketMessageType { | 7 class _WebSocketMessageType { |
| 8 static final int NONE = 0; | 8 static const int NONE = 0; |
| 9 static final int BINARY = 1; | 9 static const int BINARY = 1; |
| 10 static final int TEXT = 2; | 10 static const int TEXT = 2; |
| 11 } | 11 } |
| 12 | 12 |
| 13 | 13 |
| 14 class _WebSocketOpcode { | 14 class _WebSocketOpcode { |
| 15 static final int CONTINUATION = 0; | 15 static const int CONTINUATION = 0; |
| 16 static final int TEXT = 1; | 16 static const int TEXT = 1; |
| 17 static final int BINARY = 2; | 17 static const int BINARY = 2; |
| 18 static final int RESERVED_3 = 3; | 18 static const int RESERVED_3 = 3; |
| 19 static final int RESERVED_4 = 4; | 19 static const int RESERVED_4 = 4; |
| 20 static final int RESERVED_5 = 5; | 20 static const int RESERVED_5 = 5; |
| 21 static final int RESERVED_6 = 6; | 21 static const int RESERVED_6 = 6; |
| 22 static final int RESERVED_7 = 7; | 22 static const int RESERVED_7 = 7; |
| 23 static final int CLOSE = 8; | 23 static const int CLOSE = 8; |
| 24 static final int PING = 9; | 24 static const int PING = 9; |
| 25 static final int PONG = 10; | 25 static const int PONG = 10; |
| 26 static final int RESERVED_B = 11; | 26 static const int RESERVED_B = 11; |
| 27 static final int RESERVED_C = 12; | 27 static const int RESERVED_C = 12; |
| 28 static final int RESERVED_D = 13; | 28 static const int RESERVED_D = 13; |
| 29 static final int RESERVED_E = 14; | 29 static const int RESERVED_E = 14; |
| 30 static final int RESERVED_F = 15; | 30 static const int RESERVED_F = 15; |
| 31 } | 31 } |
| 32 | 32 |
| 33 /** | 33 /** |
| 34 * The web socket protocol processor handles the protocol byte stream | 34 * The web socket protocol processor handles the protocol byte stream |
| 35 * which is supplied through the [:update:] and [:closed:] | 35 * which is supplied through the [:update:] and [:closed:] |
| 36 * methods. As the protocol is processed the following callbacks are | 36 * methods. As the protocol is processed the following callbacks are |
| 37 * called: | 37 * called: |
| 38 * | 38 * |
| 39 * [:onMessageStart:] | 39 * [:onMessageStart:] |
| 40 * [:onMessageData:] | 40 * [:onMessageData:] |
| 41 * [:onMessageEnd:] | 41 * [:onMessageEnd:] |
| 42 * [:onClosed:] | 42 * [:onClosed:] |
| 43 * [:onError:] | 43 * [:onError:] |
| 44 * | 44 * |
| 45 */ | 45 */ |
| 46 class _WebSocketProtocolProcessor { | 46 class _WebSocketProtocolProcessor { |
| 47 static final int START = 0; | 47 static const int START = 0; |
| 48 static final int LEN_FIRST = 1; | 48 static const int LEN_FIRST = 1; |
| 49 static final int LEN_REST = 2; | 49 static const int LEN_REST = 2; |
| 50 static final int MASK = 3; | 50 static const int MASK = 3; |
| 51 static final int PAYLOAD = 4; | 51 static const int PAYLOAD = 4; |
| 52 static final int CLOSED = 5; | 52 static const int CLOSED = 5; |
| 53 static final int FAILURE = 6; | 53 static const int FAILURE = 6; |
| 54 | 54 |
| 55 _WebSocketProtocolProcessor() { | 55 _WebSocketProtocolProcessor() { |
| 56 _prepareForNextFrame(); | 56 _prepareForNextFrame(); |
| 57 _currentMessageType = _WebSocketMessageType.NONE; | 57 _currentMessageType = _WebSocketMessageType.NONE; |
| 58 } | 58 } |
| 59 | 59 |
| 60 /** | 60 /** |
| 61 * Process data received from the underlying communication channel. | 61 * Process data received from the underlying communication channel. |
| 62 */ | 62 */ |
| 63 void update(List<int> buffer, int offset, int count) { | 63 void update(List<int> buffer, int offset, int count) { |
| (...skipping 818 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 |