| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 part of dart.io; | 5 part of dart.io; |
| 6 | 6 |
| 7 const String _webSocketGUID = "258EAFA5-E914-47DA-95CA-C5AB0DC85B11"; | 7 const String _webSocketGUID = "258EAFA5-E914-47DA-95CA-C5AB0DC85B11"; |
| 8 | 8 |
| 9 // Matches _WebSocketOpcode. | 9 // Matches _WebSocketOpcode. |
| 10 class _WebSocketMessageType { | 10 class _WebSocketMessageType { |
| (...skipping 846 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 857 } | 857 } |
| 858 var protocol = response.headers.value('Sec-WebSocket-Protocol'); | 858 var protocol = response.headers.value('Sec-WebSocket-Protocol'); |
| 859 return response.detachSocket() | 859 return response.detachSocket() |
| 860 .then((socket) => new _WebSocketImpl._fromSocket(socket, protocol)); | 860 .then((socket) => new _WebSocketImpl._fromSocket(socket, protocol)); |
| 861 }); | 861 }); |
| 862 } | 862 } |
| 863 | 863 |
| 864 _WebSocketImpl._fromSocket(this._socket, this.protocol, | 864 _WebSocketImpl._fromSocket(this._socket, this.protocol, |
| 865 [this._serverSide = false]) { | 865 [this._serverSide = false]) { |
| 866 _consumer = new _WebSocketConsumer(this, _socket); | 866 _consumer = new _WebSocketConsumer(this, _socket); |
| 867 _sink = new _StreamSinkImpl(_consumer); | 867 _sink = new StreamSinkAdapter(_consumer); |
| 868 _readyState = WebSocket.OPEN; | 868 _readyState = WebSocket.OPEN; |
| 869 | 869 |
| 870 var transformer = new _WebSocketProtocolTransformer(_serverSide); | 870 var transformer = new _WebSocketProtocolTransformer(_serverSide); |
| 871 _subscription = _socket.transform(transformer).listen( | 871 _subscription = _socket.transform(transformer).listen( |
| 872 (data) { | 872 (data) { |
| 873 if (data is _WebSocketPing) { | 873 if (data is _WebSocketPing) { |
| 874 if (!_writeClosed) _consumer.add(new _WebSocketPong(data.payload)); | 874 if (!_writeClosed) _consumer.add(new _WebSocketPong(data.payload)); |
| 875 } else if (data is _WebSocketPong) { | 875 } else if (data is _WebSocketPong) { |
| 876 // Simply set pingInterval, as it'll cancel any timers. | 876 // Simply set pingInterval, as it'll cancel any timers. |
| 877 pingInterval = _pingInterval; | 877 pingInterval = _pingInterval; |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 985 (code < WebSocketStatus.NORMAL_CLOSURE || | 985 (code < WebSocketStatus.NORMAL_CLOSURE || |
| 986 code == WebSocketStatus.RESERVED_1004 || | 986 code == WebSocketStatus.RESERVED_1004 || |
| 987 code == WebSocketStatus.NO_STATUS_RECEIVED || | 987 code == WebSocketStatus.NO_STATUS_RECEIVED || |
| 988 code == WebSocketStatus.ABNORMAL_CLOSURE || | 988 code == WebSocketStatus.ABNORMAL_CLOSURE || |
| 989 (code > WebSocketStatus.INTERNAL_SERVER_ERROR && | 989 (code > WebSocketStatus.INTERNAL_SERVER_ERROR && |
| 990 code < WebSocketStatus.RESERVED_1015) || | 990 code < WebSocketStatus.RESERVED_1015) || |
| 991 (code >= WebSocketStatus.RESERVED_1015 && | 991 (code >= WebSocketStatus.RESERVED_1015 && |
| 992 code < 3000)); | 992 code < 3000)); |
| 993 } | 993 } |
| 994 } | 994 } |
| OLD | NEW |