| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 | 6 |
| 7 import 'package:crypto/crypto.dart'; | 7 import 'package:crypto/crypto.dart'; |
| 8 | 8 |
| 9 import 'copy/web_socket_impl.dart'; | 9 import '../copy/web_socket_impl.dart'; |
| 10 import 'channel.dart'; |
| 10 | 11 |
| 11 /// An implementation of the WebSocket protocol that's not specific to "dart:io" | 12 /// Use [WebSocketChannel] instead. |
| 12 /// or to any particular HTTP API. | 13 @Deprecated("Will be removed in 3.0.0.") |
| 13 /// | |
| 14 /// Because this is HTTP-API-agnostic, it doesn't handle the initial [WebSocket | |
| 15 /// handshake][]. This needs to be handled manually by the user of the code. | |
| 16 /// Once that's been done, [new CompatibleWebSocket] can be called with the | |
| 17 /// underlying socket and it will handle the remainder of the protocol. | |
| 18 /// | |
| 19 /// [WebSocket handshake]: https://tools.ietf.org/html/rfc6455#section-4 | |
| 20 abstract class CompatibleWebSocket implements Stream, StreamSink { | 14 abstract class CompatibleWebSocket implements Stream, StreamSink { |
| 21 /// The interval for sending ping signals. | 15 /// The interval for sending ping signals. |
| 22 /// | 16 /// |
| 23 /// If a ping message is not answered by a pong message from the peer, the | 17 /// If a ping message is not answered by a pong message from the peer, the |
| 24 /// `WebSocket` is assumed disconnected and the connection is closed with a | 18 /// `WebSocket` is assumed disconnected and the connection is closed with a |
| 25 /// [WebSocketStatus.GOING_AWAY] close code. When a ping signal is sent, the | 19 /// [WebSocketStatus.GOING_AWAY] close code. When a ping signal is sent, the |
| 26 /// pong message must be received within [pingInterval]. | 20 /// pong message must be received within [pingInterval]. |
| 27 /// | 21 /// |
| 28 /// There are never two outstanding pings at any given time, and the next ping | 22 /// There are never two outstanding pings at any given time, and the next ping |
| 29 /// timer starts when the pong is received. | 23 /// timer starts when the pong is received. |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 /// Closes the web socket connection. | 86 /// Closes the web socket connection. |
| 93 /// | 87 /// |
| 94 /// [closeCode] and [closeReason] are the [close code][] and [reason][] sent | 88 /// [closeCode] and [closeReason] are the [close code][] and [reason][] sent |
| 95 /// to the remote peer, respectively. If they are omitted, the peer will see | 89 /// to the remote peer, respectively. If they are omitted, the peer will see |
| 96 /// a "no status received" code with no reason. | 90 /// a "no status received" code with no reason. |
| 97 /// | 91 /// |
| 98 /// [close code]: https://tools.ietf.org/html/rfc6455#section-7.1.5 | 92 /// [close code]: https://tools.ietf.org/html/rfc6455#section-7.1.5 |
| 99 /// [reason]: https://tools.ietf.org/html/rfc6455#section-7.1.6 | 93 /// [reason]: https://tools.ietf.org/html/rfc6455#section-7.1.6 |
| 100 Future close([int closeCode, String closeReason]); | 94 Future close([int closeCode, String closeReason]); |
| 101 } | 95 } |
| 102 | |
| 103 /// An exception thrown by [CompatibleWebSocket]. | |
| 104 class CompatibleWebSocketException implements Exception { | |
| 105 final String message; | |
| 106 | |
| 107 CompatibleWebSocketException([this.message]); | |
| 108 | |
| 109 String toString() => message == null | |
| 110 ? "CompatibleWebSocketException" : | |
| 111 "CompatibleWebSocketException: $message"; | |
| 112 } | |
| OLD | NEW |