Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 /** | 5 /** |
| 6 * The web socket protocol is implemented by a HTTP server handler | 6 * The web socket protocol is implemented by a HTTP server handler |
| 7 * which can be instantiated like this: | 7 * which can be instantiated like this: |
| 8 * | 8 * |
| 9 * WebSocketHandler wsHandler = new WebSocketHandler(); | 9 * WebSocketHandler wsHandler = new WebSocketHandler(); |
|
ahe
2012/04/27 09:27:45
Code samples should be wrapped in [:CODE_HERE:].
Mads Ager (google)
2012/04/27 09:29:50
Yes, I know. But that will look horrible with the
Bob Nystrom
2012/04/27 18:06:37
I think what Mads is doing here is fine. The inden
| |
| 10 * | 10 * |
| 11 * and then its onRequest method can be assigned to the HTTP server, e.g. | 11 * and then its onRequest method can be assigned to the HTTP server, e.g. |
| 12 * | 12 * |
| 13 * server.defaultHandler = wsHandler.onRequest; | 13 * server.defaultHandler = wsHandler.onRequest; |
| 14 * | 14 * |
| 15 * or | 15 * or |
| 16 * | 16 * |
| 17 * server.addRequestHandler((req) => reg.path == "/ws", wsHandler.onRequest); | 17 * server.addRequestHandler((req) => req.path == "/ws", |
| 18 * | 18 * wsHandler.onRequest); |
| 19 */ | 19 */ |
| 20 interface WebSocketHandler default _WebSocketHandler { | 20 interface WebSocketHandler default _WebSocketHandler { |
| 21 WebSocketHandler(); | 21 WebSocketHandler(); |
| 22 | 22 |
| 23 /** | 23 /** |
| 24 * Request handler to be registered with the HTTP server. | 24 * Request handler to be registered with the HTTP server. |
| 25 */ | 25 */ |
| 26 void onRequest(HttpRequest request, HttpResponse response); | 26 void onRequest(HttpRequest request, HttpResponse response); |
| 27 | 27 |
| 28 /** | 28 /** |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 69 */ | 69 */ |
| 70 close([int status, String reason]); | 70 close([int status, String reason]); |
| 71 } | 71 } |
| 72 | 72 |
| 73 | 73 |
| 74 class WebSocketException implements Exception { | 74 class WebSocketException implements Exception { |
| 75 const WebSocketException([String this.message = ""]); | 75 const WebSocketException([String this.message = ""]); |
| 76 String toString() => "WebSocketException: $message"; | 76 String toString() => "WebSocketException: $message"; |
| 77 final String message; | 77 final String message; |
| 78 } | 78 } |
| OLD | NEW |