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 /** | 7 /** |
8 * Web socket status codes used when closing a web socket connection. | 8 * Web socket status codes used when closing a web socket connection. |
9 */ | 9 */ |
10 abstract class WebSocketStatus { | 10 abstract class WebSocketStatus { |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
119 * timer starts when the pong is received. | 119 * timer starts when the pong is received. |
120 * | 120 * |
121 * Set the [pingInterval] to `null` to disable sending ping messages. | 121 * Set the [pingInterval] to `null` to disable sending ping messages. |
122 * | 122 * |
123 * The default value is `null`. | 123 * The default value is `null`. |
124 */ | 124 */ |
125 Duration pingInterval; | 125 Duration pingInterval; |
126 | 126 |
127 /** | 127 /** |
128 * Create a new web socket connection. The URL supplied in [url] | 128 * Create a new web socket connection. The URL supplied in [url] |
129 * must use the scheme [:ws:] or [:wss:]. The [protocols] argument is | 129 * must use the scheme `ws` or `wss`. |
130 * specifying the subprotocols the client is willing to speak. | 130 * |
131 * The [protocols] argument is specifying the subprotocols the | |
132 * client is willing to speak. | |
133 * | |
134 * If [onRequest] is provided this function will be called with the | |
Lasse Reichstein Nielsen
2015/01/12 15:11:56
I don't like the "onRequest" name. Its too vague.
Søren Gjesse
2015/01/12 15:36:34
Changed to pass a map of additional headers
| |
135 * [HttpClientRequest] used to request the HTTP upgrade to the web | |
136 * socket protocol just before the request is actually sent. Use | |
137 * this if e.g. additional headers are required by the server. The | |
Lasse Reichstein Nielsen
2015/01/12 15:11:56
Commas around "e.g.": "this if, e.g., additional".
Søren Gjesse
2015/01/12 15:36:34
Rephrased comment.
| |
138 * following headers which are already set on the request should not | |
139 * be changed. | |
140 * | |
141 * connection: Upgrade | |
142 * sec-websocket-version: 13 | |
143 * sec-websocket-key: ... | |
144 * upgrade: websocket | |
Lasse Reichstein Nielsen
2015/01/12 15:11:56
Then make sure they aren't. If it's only those fou
Søren Gjesse
2015/01/12 15:36:34
Changed to pass a map of additional headers, and d
| |
145 * | |
146 * If `onRequest` returns a `Future` the request is not sent until that | |
147 * `Future` completes. | |
131 */ | 148 */ |
132 static Future<WebSocket> connect(String url, | 149 static Future<WebSocket> connect(String url, |
133 {List<String> protocols: const []}) => | 150 {List<String> protocols: const [], |
Lasse Reichstein Nielsen
2015/01/12 15:11:56
Why is "protocols" a List and not an Iterable?
I c
Søren Gjesse
2015/01/12 15:36:34
No particular reason. Changed to Iterable.
| |
134 _WebSocketImpl.connect(url, protocols); | 151 Function onRequest}) => |
kustermann
2015/01/09 14:45:12
change the signature to this:
onRequest(HttpClien
Søren Gjesse
2015/01/12 15:36:34
Changed to not use callback.
| |
152 _WebSocketImpl.connect(url, protocols, onRequest); | |
135 | 153 |
136 @Deprecated('This constructor will be removed in Dart 2.0. Use `implements`' | 154 @Deprecated('This constructor will be removed in Dart 2.0. Use `implements`' |
137 ' instead of `extends` if implementing this abstract class.') | 155 ' instead of `extends` if implementing this abstract class.') |
138 WebSocket(); | 156 WebSocket(); |
139 | 157 |
140 /** | 158 /** |
141 * Creates a WebSocket from an already-upgraded socket. | 159 * Creates a WebSocket from an already-upgraded socket. |
142 * | 160 * |
143 * The initial WebSocket handshake must have occurred prior to this call. A | 161 * The initial WebSocket handshake must have occurred prior to this call. A |
144 * WebSocket client can automatically perform the handshake using | 162 * WebSocket client can automatically perform the handshake using |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
214 */ | 232 */ |
215 Future addStream(Stream stream); | 233 Future addStream(Stream stream); |
216 } | 234 } |
217 | 235 |
218 | 236 |
219 class WebSocketException implements IOException { | 237 class WebSocketException implements IOException { |
220 final String message; | 238 final String message; |
221 const WebSocketException([this.message = ""]); | 239 const WebSocketException([this.message = ""]); |
222 String toString() => "WebSocketException: $message"; | 240 String toString() => "WebSocketException: $message"; |
223 } | 241 } |
OLD | NEW |