Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(459)

Side by Side Diff: sdk/lib/io/websocket_impl.dart

Issue 14251013: Rename unsubscribeOnError to cancelOnError. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 19 matching lines...) Expand all
30 static const int RESERVED_D = 13; 30 static const int RESERVED_D = 13;
31 static const int RESERVED_E = 14; 31 static const int RESERVED_E = 14;
32 static const int RESERVED_F = 15; 32 static const int RESERVED_F = 15;
33 } 33 }
34 34
35 /** 35 /**
36 * The web socket protocol transformer handles the protocol byte stream 36 * The web socket protocol transformer handles the protocol byte stream
37 * which is supplied through the [:handleData:]. As the protocol is processed, 37 * which is supplied through the [:handleData:]. As the protocol is processed,
38 * it'll output frame data as either a List<int> or String. 38 * it'll output frame data as either a List<int> or String.
39 * 39 *
40 * Important infomation about usage: Be sure you use unsubscribeOnError, so the 40 * Important infomation about usage: Be sure you use cancelOnError, so the
41 * socket will be closed when the processer encounter an error. Not using it 41 * socket will be closed when the processer encounter an error. Not using it
42 * will lead to undefined behaviour. 42 * will lead to undefined behaviour.
43 */ 43 */
44 class _WebSocketProtocolTransformer extends StreamEventTransformer { 44 class _WebSocketProtocolTransformer extends StreamEventTransformer {
45 static const int START = 0; 45 static const int START = 0;
46 static const int LEN_FIRST = 1; 46 static const int LEN_FIRST = 1;
47 static const int LEN_REST = 2; 47 static const int LEN_REST = 2;
48 static const int MASK = 3; 48 static const int MASK = 3;
49 static const int PAYLOAD = 4; 49 static const int PAYLOAD = 4;
50 static const int CLOSED = 5; 50 static const int CLOSED = 5;
(...skipping 489 matching lines...) Expand 10 before | Expand all | Expand 10 after
540 } else { 540 } else {
541 _close(); 541 _close();
542 } 542 }
543 _readyState = WebSocket.CLOSED; 543 _readyState = WebSocket.CLOSED;
544 } 544 }
545 _closeCode = transformer.closeCode; 545 _closeCode = transformer.closeCode;
546 _closeReason = transformer.closeReason; 546 _closeReason = transformer.closeReason;
547 _controller.close(); 547 _controller.close();
548 if (_writeClosed) _socket.destroy(); 548 if (_writeClosed) _socket.destroy();
549 }, 549 },
550 unsubscribeOnError: true); 550 cancelOnError: true);
551 551
552 _socket.done 552 _socket.done
553 .catchError((error) { 553 .catchError((error) {
554 if (closed) return; 554 if (closed) return;
555 closed = true; 555 closed = true;
556 _readyState = WebSocket.CLOSED; 556 _readyState = WebSocket.CLOSED;
557 _closeCode = WebSocketStatus.ABNORMAL_CLOSURE; 557 _closeCode = WebSocketStatus.ABNORMAL_CLOSURE;
558 _controller.addError(error); 558 _controller.addError(error);
559 _controller.close(); 559 _controller.close();
560 }) 560 })
561 .whenComplete(() { 561 .whenComplete(() {
562 _writeClosed = true; 562 _writeClosed = true;
563 }); 563 });
564 } 564 }
565 565
566 StreamSubscription listen(void onData(message), 566 StreamSubscription listen(void onData(message),
567 {void onError(AsyncError error), 567 {void onError(AsyncError error),
568 void onDone(), 568 void onDone(),
569 bool unsubscribeOnError}) { 569 bool cancelOnError}) {
570 return _controller.stream.listen(onData, 570 return _controller.stream.listen(onData,
571 onError: onError, 571 onError: onError,
572 onDone: onDone, 572 onDone: onDone,
573 unsubscribeOnError: unsubscribeOnError); 573 cancelOnError: cancelOnError);
574 } 574 }
575 575
576 int get readyState => _readyState; 576 int get readyState => _readyState;
577 577
578 String get extensions => null; 578 String get extensions => null;
579 String get protocol => null; 579 String get protocol => null;
580 int get closeCode => _closeCode; 580 int get closeCode => _closeCode;
581 String get closeReason => _closeReason; 581 String get closeReason => _closeReason;
582 582
583 void close([int code, String reason]) { 583 void close([int code, String reason]) {
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
687 if (data != null) { 687 if (data != null) {
688 _socket.add(data); 688 _socket.add(data);
689 } 689 }
690 } catch (_) { 690 } catch (_) {
691 // The socket can be closed before _socket.done have a chance 691 // The socket can be closed before _socket.done have a chance
692 // to complete. 692 // to complete.
693 _writeClosed = true; 693 _writeClosed = true;
694 } 694 }
695 } 695 }
696 } 696 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698