| 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(); |
| 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) => req.path == "/ws", | 17 * server.addRequestHandler((req) => req.path == "/ws", |
| 18 * wsHandler.onRequest); | 18 * wsHandler.onRequest); |
| 19 * |
| 20 * This handler strives to implement web sockets as specified by RFC6455. |
| 19 */ | 21 */ |
| 20 interface WebSocketHandler default _WebSocketHandler { | 22 interface WebSocketHandler default _WebSocketHandler { |
| 21 WebSocketHandler(); | 23 WebSocketHandler(); |
| 22 | 24 |
| 23 /** | 25 /** |
| 24 * Request handler to be registered with the HTTP server. | 26 * Request handler to be registered with the HTTP server. |
| 25 */ | 27 */ |
| 26 void onRequest(HttpRequest request, HttpResponse response); | 28 void onRequest(HttpRequest request, HttpResponse response); |
| 27 | 29 |
| 28 /** | 30 /** |
| (...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 276 */ | 278 */ |
| 277 void send(data); | 279 void send(data); |
| 278 } | 280 } |
| 279 | 281 |
| 280 | 282 |
| 281 class WebSocketException implements Exception { | 283 class WebSocketException implements Exception { |
| 282 const WebSocketException([String this.message = ""]); | 284 const WebSocketException([String this.message = ""]); |
| 283 String toString() => "WebSocketException: $message"; | 285 String toString() => "WebSocketException: $message"; |
| 284 final String message; | 286 final String message; |
| 285 } | 287 } |
| OLD | NEW |