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 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 * Creates a WebSocket from an already-upgraded socket. | 137 * Creates a WebSocket from an already-upgraded socket. |
138 * | 138 * |
139 * The initial WebSocket handshake must have occurred prior to this call. A | 139 * The initial WebSocket handshake must have occurred prior to this call. A |
140 * WebSocket client can automatically perform the handshake using | 140 * WebSocket client can automatically perform the handshake using |
141 * [WebSocket.connect], while a server can do so using | 141 * [WebSocket.connect], while a server can do so using |
142 * [WebSocketTransformer.upgrade]. To manually upgrade an [HttpRequest], | 142 * [WebSocketTransformer.upgrade]. To manually upgrade an [HttpRequest], |
143 * [HttpRequest.detachSocket] may be called. | 143 * [HttpRequest.detachSocket] may be called. |
144 * | 144 * |
145 * [protocol] should be the protocol negotiated by this handshake, if any. | 145 * [protocol] should be the protocol negotiated by this handshake, if any. |
146 * | 146 * |
147 * If [serverSide] is `false`, the WebSocket will act as the client and mask | 147 * [serverSide] must be passed explicitly. If it's `false`, the WebSocket will |
148 * the messages it sends. If it's `true`, it will act as the server and will | 148 * act as the client and mask the messages it sends. If it's `true`, it will |
149 * not mask its messages. | 149 * act as the server and will not mask its messages. |
150 */ | 150 */ |
151 factory WebSocket.fromUpgradedSocket(Socket socket, {String protocol, | 151 factory WebSocket.fromUpgradedSocket(Socket socket, {String protocol, |
152 bool serverSide: true}) => | 152 bool serverSide}) { |
153 new _WebSocketImpl._fromSocket(socket, protocol, serverSide); | 153 if (serverSide == null) { |
| 154 throw new ArgumentError("The serverSide argument must be passed " |
| 155 "explicitly to WebSocket.fromUpgradedSocket."); |
| 156 } |
| 157 return new _WebSocketImpl._fromSocket(socket, protocol, serverSide); |
| 158 } |
154 | 159 |
155 /** | 160 /** |
156 * Returns the current state of the connection. | 161 * Returns the current state of the connection. |
157 */ | 162 */ |
158 int get readyState; | 163 int get readyState; |
159 | 164 |
160 /** | 165 /** |
161 * The extensions property is initially the empty string. After the | 166 * The extensions property is initially the empty string. After the |
162 * web socket connection is established this string reflects the | 167 * web socket connection is established this string reflects the |
163 * extensions used by the server. | 168 * extensions used by the server. |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
205 */ | 210 */ |
206 Future addStream(Stream stream); | 211 Future addStream(Stream stream); |
207 } | 212 } |
208 | 213 |
209 | 214 |
210 class WebSocketException implements IOException { | 215 class WebSocketException implements IOException { |
211 final String message; | 216 final String message; |
212 const WebSocketException([this.message = ""]); | 217 const WebSocketException([this.message = ""]); |
213 String toString() => "WebSocketException: $message"; | 218 String toString() => "WebSocketException: $message"; |
214 } | 219 } |
OLD | NEW |