Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(431)

Side by Side Diff: runtime/bin/websocket.dart

Issue 10205012: Initial web socket server implementation (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Addressed review comments from vsm@ Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/bin/sha1.dart ('k') | runtime/bin/websocket_impl.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // BSD-style license that can be found in the LICENSE file.
4
5 /**
6 * The web socket protocol is implemented by a HTTP server handler
7 * which can be instantiated like this:
8 *
9 * WebSocketHandler wsHandler = new WebSocketHandler();
10 *
11 * and then its onRequest method can be assigned to the HTTP server, e.g.
12 *
13 * server.defaultHandler = wsHandler.onRequest;
14 *
15 * or
16 *
17 * server.addRequestHandler((req) => reg.path == "/ws", wsHandler.onRequest);
18 *
19 */
20 interface WebSocketHandler default _WebSocketHandler {
21 WebSocketHandler();
22
23 /**
24 * Request handler to be registered with the HTTP server.
25 */
26 void onRequest(HttpRequest request, HttpResponse response);
27
28 /**
29 * Sets the callback to be called when a new web socket connection
30 * has been established.
31 */
32 void set onOpen(callback(WebSocketConnection connection));
33 }
34
35
36 /**
37 * Web socket connection.
38 */
39 interface WebSocketConnection {
40 /**
41 * Sets the callback to be called when a message have been
42 * received. The type on [message] is either [:String:] or
43 * [:List<int>:] depending on whether it is a text or binary
44 * message. If the message is empty [message] will be [:null:].
45 */
46 void set onMessage(void callback(message));
47
48 /**
49 * Sets the callback to be called when the web socket connection is
50 * closed.
51 */
52 void set onClosed(void callback(int status, String reason));
53
54 /**
55 * Sets the callback to be called when the web socket connection
56 * encountered an error.
57 */
58 void set onError(void callback(e));
59
60 /**
61 * Sends a message. The [message] must be a [:String:] a
62 * [:List<int>:] or [:null:].
63 */
64 send(Object message);
65
66 /**
67 * Close the web socket connection. The default value for [status]
68 * and [reason] are [:null:].
69 */
70 close([int status, String reason]);
71 }
72
73
74 class WebSocketException implements Exception {
75 const WebSocketException([String this.message = ""]);
76 String toString() => "WebSocketException: $message";
77 final String message;
78 }
OLDNEW
« no previous file with comments | « runtime/bin/sha1.dart ('k') | runtime/bin/websocket_impl.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698