OLD | NEW |
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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 import 'dart:async'; | 5 import 'dart:async'; |
6 import 'dart:convert' as convert; | 6 import 'dart:convert' as convert; |
7 | 7 |
8 import 'package:async/async.dart'; | 8 import 'package:async/async.dart'; |
9 import 'package:crypto/crypto.dart'; | 9 import 'package:crypto/crypto.dart'; |
10 import 'package:stream_channel/stream_channel.dart'; | 10 import 'package:stream_channel/stream_channel.dart'; |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 } | 97 } |
98 | 98 |
99 /// The sink exposed by a [WebSocketChannel]. | 99 /// The sink exposed by a [WebSocketChannel]. |
100 /// | 100 /// |
101 /// This is like a normal [StreamSink], except that it supports extra arguments | 101 /// This is like a normal [StreamSink], except that it supports extra arguments |
102 /// to [close]. | 102 /// to [close]. |
103 class WebSocketSink extends DelegatingStreamSink { | 103 class WebSocketSink extends DelegatingStreamSink { |
104 final WebSocketImpl _webSocket; | 104 final WebSocketImpl _webSocket; |
105 | 105 |
106 WebSocketSink._(WebSocketImpl webSocket) | 106 WebSocketSink._(WebSocketImpl webSocket) |
107 : super(webSocket), | 107 : _webSocket = webSocket, |
108 _webSocket = webSocket; | 108 super(webSocket); |
109 | 109 |
110 /// Closes the web socket connection. | 110 /// Closes the web socket connection. |
111 /// | 111 /// |
112 /// [closeCode] and [closeReason] are the [close code][] and [reason][] sent | 112 /// [closeCode] and [closeReason] are the [close code][] and [reason][] sent |
113 /// to the remote peer, respectively. If they are omitted, the peer will see | 113 /// to the remote peer, respectively. If they are omitted, the peer will see |
114 /// a "no status received" code with no reason. | 114 /// a "no status received" code with no reason. |
115 /// | 115 /// |
116 /// [close code]: https://tools.ietf.org/html/rfc6455#section-7.1.5 | 116 /// [close code]: https://tools.ietf.org/html/rfc6455#section-7.1.5 |
117 /// [reason]: https://tools.ietf.org/html/rfc6455#section-7.1.6 | 117 /// [reason]: https://tools.ietf.org/html/rfc6455#section-7.1.6 |
118 Future close([int closeCode, String closeReason]) => | 118 Future close([int closeCode, String closeReason]) => |
119 _webSocket.close(closeCode, closeReason); | 119 _webSocket.close(closeCode, closeReason); |
120 } | 120 } |
OLD | NEW |