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 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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:]. The [protocols] argument is |
130 * specifying the subprotocols the client is willing to speak. | 130 * specifying the subprotocols the client is willing to speak. |
131 */ | 131 */ |
132 static Future<WebSocket> connect(String url, | 132 static Future<WebSocket> connect(String url, |
133 {List<String> protocols: const []}) => | 133 {List<String> protocols: const []}) => |
134 _WebSocketImpl.connect(url, protocols); | 134 _WebSocketImpl.connect(url, protocols); |
135 | 135 |
136 /** | 136 /** |
kasperl
2014/05/05 09:31:51
How bad would it be to add a (deprecated) default
Anders Johnsen
2014/05/05 09:33:49
Would it be okay if the WebSocket constructor thro
nweiz
2014/05/05 19:21:03
Wouldn't that also break users using "extend WebSo
| |
137 * Creates a WebSocket from an already-upgraded socket. | |
138 * | |
139 * The initial WebSocket handshake must have occurred prior to this call. A | |
140 * WebSocket client can automatically perform the handshake using | |
141 * [WebSocket.connect], while a server can do so using | |
142 * [WebSocketTransformer.upgrade]. To manually upgrade an [HttpRequest], | |
143 * [HttpRequest.detachSocket] may be called. | |
144 * | |
145 * [protocol] should be the protocol negotiated by this handshake, if any. | |
146 * | |
147 * If [serverSide] is `false`, the WebSocket will act as the client and mask | |
148 * the messages it sends. If it's `true`, it will act as the server and will | |
149 * not mask its messages. | |
150 */ | |
151 factory WebSocket.fromUpgradedSocket(Socket socket, {String protocol, | |
152 bool serverSide: true}) => | |
153 new _WebSocketImpl._fromSocket(socket, protocol, serverSide); | |
154 | |
155 /** | |
137 * Returns the current state of the connection. | 156 * Returns the current state of the connection. |
138 */ | 157 */ |
139 int get readyState; | 158 int get readyState; |
140 | 159 |
141 /** | 160 /** |
142 * The extensions property is initially the empty string. After the | 161 * The extensions property is initially the empty string. After the |
143 * web socket connection is established this string reflects the | 162 * web socket connection is established this string reflects the |
144 * extensions used by the server. | 163 * extensions used by the server. |
145 */ | 164 */ |
146 String get extensions; | 165 String get extensions; |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
186 */ | 205 */ |
187 Future addStream(Stream stream); | 206 Future addStream(Stream stream); |
188 } | 207 } |
189 | 208 |
190 | 209 |
191 class WebSocketException implements IOException { | 210 class WebSocketException implements IOException { |
192 final String message; | 211 final String message; |
193 const WebSocketException([this.message = ""]); | 212 const WebSocketException([this.message = ""]); |
194 String toString() => "WebSocketException: $message"; | 213 String toString() => "WebSocketException: $message"; |
195 } | 214 } |
OLD | NEW |