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

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

Issue 10907211: Add web socket error codes constants (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 3 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 | « no previous file | 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
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 * Web socket status codes used when closing a web socket connection.
7 */
8 interface WebSocketStatus {
9 static const int NORMAL_CLOSURE = 1000;
10 static const int GOING_AWAY = 1001;
11 static const int PROTOCOL_ERROR = 1002;
12 static const int UNSUPPORTED_DATA = 1003;
13 static const int RESERVED_1004 = 1004;
14 static const int NO_STATUS_RECEIVED = 1005;
15 static const int ABNORMAL_CLOSURE = 1006;
16 static const int INVALID_FRAME_PAYLOAD_DATA = 1007;
17 static const int POLICY_VIOLATION = 1008;
18 static const int MESSAGE_TOO_BIG = 1009;
19 static const int MISSING_MANDATORY_EXTENSION = 1010;
20 static const int INTERNAL_SERVER_ERROR = 1011;
21 static const int RESERVED_1015 = 1015;
22 }
23
24 /**
6 * The web socket protocol is implemented by a HTTP server handler 25 * The web socket protocol is implemented by a HTTP server handler
7 * which can be instantiated like this: 26 * which can be instantiated like this:
8 * 27 *
9 * WebSocketHandler wsHandler = new WebSocketHandler(); 28 * WebSocketHandler wsHandler = new WebSocketHandler();
10 * 29 *
11 * and then its onRequest method can be assigned to the HTTP server, e.g. 30 * and then its onRequest method can be assigned to the HTTP server, e.g.
12 * 31 *
13 * server.defaultHandler = wsHandler.onRequest; 32 * server.defaultHandler = wsHandler.onRequest;
14 * 33 *
15 * or 34 * or
(...skipping 26 matching lines...) Expand all
42 /** 61 /**
43 * Sets the callback to be called when a message have been 62 * Sets the callback to be called when a message have been
44 * received. The type on [message] is either [:String:] or 63 * received. The type on [message] is either [:String:] or
45 * [:List<int>:] depending on whether it is a text or binary 64 * [:List<int>:] depending on whether it is a text or binary
46 * message. If the message is empty [message] will be [:null:]. 65 * message. If the message is empty [message] will be [:null:].
47 */ 66 */
48 void set onMessage(void callback(message)); 67 void set onMessage(void callback(message));
49 68
50 /** 69 /**
51 * Sets the callback to be called when the web socket connection is 70 * Sets the callback to be called when the web socket connection is
52 * closed. 71 * closed. [status] indicate the reason for closing. For network
72 * errors the value of [status] will be
73 * WebSocketStatus.ABNORMAL_CLOSURE].
53 */ 74 */
54 void set onClosed(void callback(int status, String reason)); 75 void set onClosed(void callback(int status, String reason));
55 76
56 /** 77 /**
57 * Sends a message. The [message] must be a [:String:] a 78 * Sends a message. The [message] must be a [:String:] a
58 * [:List<int>:] or [:null:]. 79 * [:List<int>:] or [:null:].
59 */ 80 */
60 send(Object message); 81 send(Object message);
61 82
62 /** 83 /**
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 /** 122 /**
102 * Sets the callback to be called when a message have been 123 * Sets the callback to be called when a message have been
103 * received. The type of [message] is either [:String:] or 124 * received. The type of [message] is either [:String:] or
104 * [:List<int>:] depending on whether it is a text or binary 125 * [:List<int>:] depending on whether it is a text or binary
105 * message. If the message is empty [message] will be [:null:]. 126 * message. If the message is empty [message] will be [:null:].
106 */ 127 */
107 void set onMessage(void callback(message)); 128 void set onMessage(void callback(message));
108 129
109 /** 130 /**
110 * Sets the callback to be called when the web socket connection is 131 * Sets the callback to be called when the web socket connection is
111 * closed. 132 * closed. [status] indicate the reason for closing. For network
133 * errors the value of [status] will be
134 * WebSocketStatus.ABNORMAL_CLOSURE].
112 */ 135 */
113 void set onClosed(void callback(int status, String reason)); 136 void set onClosed(void callback(int status, String reason));
114 137
115 /** 138 /**
116 * Sets the callback to be called when the response object for the 139 * Sets the callback to be called when the response object for the
117 * opening handshake did not cause a web socket connection 140 * opening handshake did not cause a web socket connection
118 * upgrade. This will be called in case the response status code is 141 * upgrade. This will be called in case the response status code is
119 * not 101 (Switching Protocols). If this callback is not set the 142 * not 101 (Switching Protocols). If this callback is not set the
120 * [:onError:] callback will be called if the server did not upgrade 143 * [:onError:] callback will be called if the server did not upgrade
121 * the connection. 144 * the connection.
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
266 */ 289 */
267 void send(data); 290 void send(data);
268 } 291 }
269 292
270 293
271 class WebSocketException implements Exception { 294 class WebSocketException implements Exception {
272 const WebSocketException([String this.message = ""]); 295 const WebSocketException([String this.message = ""]);
273 String toString() => "WebSocketException: $message"; 296 String toString() => "WebSocketException: $message";
274 final String message; 297 final String message;
275 } 298 }
OLDNEW
« no previous file with comments | « no previous file | runtime/bin/websocket_impl.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698