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 class _WebSocketMessageType { | 9 class _WebSocketMessageType { |
10 static const int NONE = 0; | 10 static const int NONE = 0; |
(...skipping 567 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
578 }, | 578 }, |
579 onError: (error) { | 579 onError: (error) { |
580 if (!_done(error)) { | 580 if (!_done(error)) { |
581 _closeCompleter.completeError(error); | 581 _closeCompleter.completeError(error); |
582 } | 582 } |
583 }); | 583 }); |
584 } | 584 } |
585 | 585 |
586 bool _done([error]) { | 586 bool _done([error]) { |
587 if (_completer == null) return false; | 587 if (_completer == null) return false; |
588 var tmp = _completer; | 588 if (error != null) { |
| 589 _completer.completeError(error); |
| 590 } else { |
| 591 _completer.complete(webSocket); |
| 592 } |
589 _completer = null; | 593 _completer = null; |
590 if (error != null) { | |
591 tmp.completeError(error); | |
592 } else { | |
593 tmp.complete(webSocket); | |
594 } | |
595 return true; | 594 return true; |
596 } | 595 } |
597 | 596 |
598 Future addStream(var stream) { | 597 Future addStream(var stream) { |
599 _ensureController(); | 598 _ensureController(); |
600 _completer = new Completer(); | 599 _completer = new Completer(); |
601 _subscription = stream.listen( | 600 _subscription = stream.listen( |
602 (data) { | 601 (data) { |
603 _controller.add(data); | 602 _controller.add(data); |
604 }, | 603 }, |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
796 (code < WebSocketStatus.NORMAL_CLOSURE || | 795 (code < WebSocketStatus.NORMAL_CLOSURE || |
797 code == WebSocketStatus.RESERVED_1004 || | 796 code == WebSocketStatus.RESERVED_1004 || |
798 code == WebSocketStatus.NO_STATUS_RECEIVED || | 797 code == WebSocketStatus.NO_STATUS_RECEIVED || |
799 code == WebSocketStatus.ABNORMAL_CLOSURE || | 798 code == WebSocketStatus.ABNORMAL_CLOSURE || |
800 (code > WebSocketStatus.INTERNAL_SERVER_ERROR && | 799 (code > WebSocketStatus.INTERNAL_SERVER_ERROR && |
801 code < WebSocketStatus.RESERVED_1015) || | 800 code < WebSocketStatus.RESERVED_1015) || |
802 (code >= WebSocketStatus.RESERVED_1015 && | 801 (code >= WebSocketStatus.RESERVED_1015 && |
803 code < 3000)); | 802 code < 3000)); |
804 } | 803 } |
805 } | 804 } |
OLD | NEW |