| 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 396 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 407 throw new WebSocketException("Connection closed"); | 407 throw new WebSocketException("Connection closed"); |
| 408 } | 408 } |
| 409 List<int> data; | 409 List<int> data; |
| 410 int opcode; | 410 int opcode; |
| 411 if (message !== null) { | 411 if (message !== null) { |
| 412 if (message is String) { | 412 if (message is String) { |
| 413 opcode = _WebSocketOpcode.TEXT; | 413 opcode = _WebSocketOpcode.TEXT; |
| 414 data = _StringEncoders.encoder(Encoding.UTF_8).encodeString(message); | 414 data = _StringEncoders.encoder(Encoding.UTF_8).encodeString(message); |
| 415 } else { | 415 } else { |
| 416 if (message is !List<int>) { | 416 if (message is !List<int>) { |
| 417 throw new IllegalArgumentException(message); | 417 throw new ArgumentError(message); |
| 418 } | 418 } |
| 419 opcode = _WebSocketOpcode.BINARY; | 419 opcode = _WebSocketOpcode.BINARY; |
| 420 data = message; | 420 data = message; |
| 421 } | 421 } |
| 422 } else { | 422 } else { |
| 423 opcode = _WebSocketOpcode.TEXT; | 423 opcode = _WebSocketOpcode.TEXT; |
| 424 } | 424 } |
| 425 _sendFrame(opcode, data); | 425 _sendFrame(opcode, data); |
| 426 } | 426 } |
| 427 | 427 |
| (...skipping 436 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 864 | 864 |
| 865 class _WebSocketCloseEvent implements CloseEvent { | 865 class _WebSocketCloseEvent implements CloseEvent { |
| 866 _WebSocketCloseEvent(this._wasClean, this._code, this._reason); | 866 _WebSocketCloseEvent(this._wasClean, this._code, this._reason); |
| 867 bool get wasClean => _wasClean; | 867 bool get wasClean => _wasClean; |
| 868 int get code => _code; | 868 int get code => _code; |
| 869 String get reason => _reason; | 869 String get reason => _reason; |
| 870 bool _wasClean; | 870 bool _wasClean; |
| 871 int _code; | 871 int _code; |
| 872 String _reason; | 872 String _reason; |
| 873 } | 873 } |
| OLD | NEW |