Chromium Code Reviews| 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 16 matching lines...) Expand all Loading... | |
| 27 * The [WebSocketTransformer] provides the ability to upgrade a | 27 * The [WebSocketTransformer] provides the ability to upgrade a |
| 28 * [HttpRequest] to a [WebSocket] connection. It supports both | 28 * [HttpRequest] to a [WebSocket] connection. It supports both |
| 29 * upgrading a single [HttpRequest] and upgrading a stream of | 29 * upgrading a single [HttpRequest] and upgrading a stream of |
| 30 * [HttpRequest]s. | 30 * [HttpRequest]s. |
| 31 * | 31 * |
| 32 * To upgrade a single [HttpRequest] use the static [upgrade] method. | 32 * To upgrade a single [HttpRequest] use the static [upgrade] method. |
| 33 * | 33 * |
| 34 * HttpServer server; | 34 * HttpServer server; |
| 35 * server.listen((request) { | 35 * server.listen((request) { |
| 36 * if (...) { | 36 * if (...) { |
| 37 * WebSocketTransformer.upgrade(request).then(websocket) { | 37 * WebSocketTransformer.upgrade(request).then((websocket) { |
| 38 * ... | 38 * ... |
| 39 * } | 39 * } |
|
Søren Gjesse
2013/05/08 12:15:40
});
Anders Johnsen
2013/06/11 12:23:47
Done.
| |
| 40 * } else { | 40 * } else { |
| 41 * // Do normal HTTP request processing. | 41 * // Do normal HTTP request processing. |
| 42 * } | 42 * } |
| 43 * }); | 43 * }); |
| 44 * | 44 * |
| 45 * To transform a stream of [HttpRequest] events as it implements a | 45 * To transform a stream of [HttpRequest] events as it implements a |
| 46 * stream transformer that transforms a stream of HttpRequest into a | 46 * stream transformer that transforms a stream of HttpRequest into a |
| 47 * stream of WebSockets by upgrading each HttpRequest from the HTTP or | 47 * stream of WebSockets by upgrading each HttpRequest from the HTTP or |
| 48 * HTTPS server, to the WebSocket protocol. | 48 * HTTPS server, to the WebSocket protocol. |
| 49 * | 49 * |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 151 */ | 151 */ |
| 152 Future addStream(Stream stream); | 152 Future addStream(Stream stream); |
| 153 } | 153 } |
| 154 | 154 |
| 155 | 155 |
| 156 class WebSocketException implements Exception { | 156 class WebSocketException implements Exception { |
| 157 const WebSocketException([String this.message = ""]); | 157 const WebSocketException([String this.message = ""]); |
| 158 String toString() => "WebSocketException: $message"; | 158 String toString() => "WebSocketException: $message"; |
| 159 final String message; | 159 final String message; |
| 160 } | 160 } |
| OLD | NEW |