| 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 const String _clientNoContextTakeover = "client_no_context_takeover"; | 8 const String _clientNoContextTakeover = "client_no_context_takeover"; | 
| 9 const String _serverNoContextTakeover = "server_no_context_takeover"; | 9 const String _serverNoContextTakeover = "server_no_context_takeover"; | 
| 10 const String _clientMaxWindowBits = "client_max_window_bits"; | 10 const String _clientMaxWindowBits = "client_max_window_bits"; | 
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 98   Stream bind(Stream stream) { | 98   Stream bind(Stream stream) { | 
| 99     return new Stream.eventTransformed(stream, (EventSink eventSink) { | 99     return new Stream.eventTransformed(stream, (EventSink eventSink) { | 
| 100       if (_eventSink != null) { | 100       if (_eventSink != null) { | 
| 101         throw new StateError("WebSocket transformer already used."); | 101         throw new StateError("WebSocket transformer already used."); | 
| 102       } | 102       } | 
| 103       _eventSink = eventSink; | 103       _eventSink = eventSink; | 
| 104       return this; | 104       return this; | 
| 105     }); | 105     }); | 
| 106   } | 106   } | 
| 107 | 107 | 
| 108   void addError(Object error, [StackTrace stackTrace]) => | 108   void addError(Object error, [StackTrace stackTrace]) { | 
| 109       _eventSink.addError(error, stackTrace); | 109     _eventSink.addError(error, stackTrace); | 
|  | 110   } | 
| 110 | 111 | 
| 111   void close() => _eventSink.close(); | 112   void close() { _eventSink.close(); } | 
| 112 | 113 | 
| 113   /** | 114   /** | 
| 114    * Process data received from the underlying communication channel. | 115    * Process data received from the underlying communication channel. | 
| 115    */ | 116    */ | 
| 116   void add(Uint8List buffer) { | 117   void add(Uint8List buffer) { | 
| 117     int index = 0; | 118     int index = 0; | 
| 118     int lastIndex = buffer.length; | 119     int lastIndex = buffer.length; | 
| 119     if (_state == CLOSED) { | 120     if (_state == CLOSED) { | 
| 120       throw new WebSocketException("Data on closed connection"); | 121       throw new WebSocketException("Data on closed connection"); | 
| 121     } | 122     } | 
| (...skipping 548 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 670 | 671 | 
| 671       if (_deflateHelper != null) { | 672       if (_deflateHelper != null) { | 
| 672         data = _deflateHelper.processOutgoingMessage(data); | 673         data = _deflateHelper.processOutgoingMessage(data); | 
| 673       } | 674       } | 
| 674     } else { | 675     } else { | 
| 675       opcode = _WebSocketOpcode.TEXT; | 676       opcode = _WebSocketOpcode.TEXT; | 
| 676     } | 677     } | 
| 677     addFrame(opcode, data); | 678     addFrame(opcode, data); | 
| 678   } | 679   } | 
| 679 | 680 | 
| 680   void addError(Object error, [StackTrace stackTrace]) => | 681   void addError(Object error, [StackTrace stackTrace]) { | 
| 681       _eventSink.addError(error, stackTrace); | 682     _eventSink.addError(error, stackTrace); | 
|  | 683   } | 
| 682 | 684 | 
| 683   void close() { | 685   void close() { | 
| 684     int code = webSocket._outCloseCode; | 686     int code = webSocket._outCloseCode; | 
| 685     String reason = webSocket._outCloseReason; | 687     String reason = webSocket._outCloseReason; | 
| 686     List<int> data; | 688     List<int> data; | 
| 687     if (code != null) { | 689     if (code != null) { | 
| 688       data = new List<int>(); | 690       data = new List<int>(); | 
| 689       data.add((code >> 8) & 0xFF); | 691       data.add((code >> 8) & 0xFF); | 
| 690       data.add(code & 0xFF); | 692       data.add(code & 0xFF); | 
| 691       if (reason != null) { | 693       if (reason != null) { | 
| (...skipping 462 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1154       }); | 1156       }); | 
| 1155     }); | 1157     }); | 
| 1156   } | 1158   } | 
| 1157 | 1159 | 
| 1158   int get readyState => _readyState; | 1160   int get readyState => _readyState; | 
| 1159 | 1161 | 
| 1160   String get extensions => null; | 1162   String get extensions => null; | 
| 1161   int get closeCode => _closeCode; | 1163   int get closeCode => _closeCode; | 
| 1162   String get closeReason => _closeReason; | 1164   String get closeReason => _closeReason; | 
| 1163 | 1165 | 
| 1164   void add(data) => _sink.add(data); | 1166   void add(data) { _sink.add(data); } | 
| 1165   void addError(error, [StackTrace stackTrace]) => | 1167   void addError(error, [StackTrace stackTrace]) { | 
| 1166       _sink.addError(error, stackTrace); | 1168     _sink.addError(error, stackTrace); | 
|  | 1169   } | 
| 1167   Future addStream(Stream stream) => _sink.addStream(stream); | 1170   Future addStream(Stream stream) => _sink.addStream(stream); | 
| 1168   Future get done => _sink.done; | 1171   Future get done => _sink.done; | 
| 1169 | 1172 | 
| 1170   Future close([int code, String reason]) { | 1173   Future close([int code, String reason]) { | 
| 1171     if (_isReservedStatusCode(code)) { | 1174     if (_isReservedStatusCode(code)) { | 
| 1172       throw new WebSocketException("Reserved status code $code"); | 1175       throw new WebSocketException("Reserved status code $code"); | 
| 1173     } | 1176     } | 
| 1174     if (_outCloseCode == null) { | 1177     if (_outCloseCode == null) { | 
| 1175       _outCloseCode = code; | 1178       _outCloseCode = code; | 
| 1176       _outCloseReason = reason; | 1179       _outCloseReason = reason; | 
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1241     return code != null && | 1244     return code != null && | 
| 1242         (code < WebSocketStatus.NORMAL_CLOSURE || | 1245         (code < WebSocketStatus.NORMAL_CLOSURE || | 
| 1243             code == WebSocketStatus.RESERVED_1004 || | 1246             code == WebSocketStatus.RESERVED_1004 || | 
| 1244             code == WebSocketStatus.NO_STATUS_RECEIVED || | 1247             code == WebSocketStatus.NO_STATUS_RECEIVED || | 
| 1245             code == WebSocketStatus.ABNORMAL_CLOSURE || | 1248             code == WebSocketStatus.ABNORMAL_CLOSURE || | 
| 1246             (code > WebSocketStatus.INTERNAL_SERVER_ERROR && | 1249             (code > WebSocketStatus.INTERNAL_SERVER_ERROR && | 
| 1247                 code < WebSocketStatus.RESERVED_1015) || | 1250                 code < WebSocketStatus.RESERVED_1015) || | 
| 1248             (code >= WebSocketStatus.RESERVED_1015 && code < 3000)); | 1251             (code >= WebSocketStatus.RESERVED_1015 && code < 3000)); | 
| 1249   } | 1252   } | 
| 1250 } | 1253 } | 
| OLD | NEW | 
|---|