| 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 const 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 const int NONE = 0; | 8 static const int NONE = 0; |
| 9 static const int BINARY = 1; | 9 static const int BINARY = 1; |
| 10 static const int TEXT = 2; | 10 static const int TEXT = 2; |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 183 index += payload; | 183 index += payload; |
| 184 } | 184 } |
| 185 | 185 |
| 186 if (_remainingPayloadBytes == 0) { | 186 if (_remainingPayloadBytes == 0) { |
| 187 _controlFrameEnd(); | 187 _controlFrameEnd(); |
| 188 } | 188 } |
| 189 } else { | 189 } else { |
| 190 switch (_currentMessageType) { | 190 switch (_currentMessageType) { |
| 191 case _WebSocketMessageType.NONE: | 191 case _WebSocketMessageType.NONE: |
| 192 throw new WebSocketException("Protocol error"); | 192 throw new WebSocketException("Protocol error"); |
| 193 break; | |
| 194 | 193 |
| 195 case _WebSocketMessageType.TEXT: | 194 case _WebSocketMessageType.TEXT: |
| 196 case _WebSocketMessageType.BINARY: | 195 case _WebSocketMessageType.BINARY: |
| 197 if (onMessageData !== null) { | 196 if (onMessageData !== null) { |
| 198 onMessageData(buffer, index, payload); | 197 onMessageData(buffer, index, payload); |
| 199 } | 198 } |
| 200 index += payload; | 199 index += payload; |
| 201 if (_remainingPayloadBytes == 0) { | 200 if (_remainingPayloadBytes == 0) { |
| 202 _messageFrameEnd(); | 201 _messageFrameEnd(); |
| 203 } | 202 } |
| 204 break; | 203 break; |
| 205 | 204 |
| 206 default: | 205 default: |
| 207 throw new WebSocketException("Protocol error"); | 206 throw new WebSocketException("Protocol error"); |
| 208 break; | |
| 209 | 207 |
| 210 } | 208 } |
| 211 } | 209 } |
| 212 | 210 |
| 213 // Hack - as we always do index++ below. | 211 // Hack - as we always do index++ below. |
| 214 index--; | 212 index--; |
| 215 } | 213 } |
| 216 | 214 |
| 217 // Move to the next byte. | 215 // Move to the next byte. |
| 218 index++; | 216 index++; |
| (...skipping 631 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 850 | 848 |
| 851 class _WebSocketCloseEvent implements CloseEvent { | 849 class _WebSocketCloseEvent implements CloseEvent { |
| 852 _WebSocketCloseEvent(this._wasClean, this._code, this._reason); | 850 _WebSocketCloseEvent(this._wasClean, this._code, this._reason); |
| 853 bool get wasClean => _wasClean; | 851 bool get wasClean => _wasClean; |
| 854 int get code => _code; | 852 int get code => _code; |
| 855 String get reason => _reason; | 853 String get reason => _reason; |
| 856 bool _wasClean; | 854 bool _wasClean; |
| 857 int _code; | 855 int _code; |
| 858 String _reason; | 856 String _reason; |
| 859 } | 857 } |
| OLD | NEW |