| 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 * Web socket status codes used when closing a web socket connection. | 6 * Web socket status codes used when closing a web socket connection. |
| 7 */ | 7 */ |
| 8 interface WebSocketStatus { | 8 interface WebSocketStatus { |
| 9 static const int NORMAL_CLOSURE = 1000; | 9 static const int NORMAL_CLOSURE = 1000; |
| 10 static const int GOING_AWAY = 1001; | 10 static const int GOING_AWAY = 1001; |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 * received. The type on [message] is either [:String:] or | 63 * received. The type on [message] is either [:String:] or |
| 64 * [:List<int>:] depending on whether it is a text or binary | 64 * [:List<int>:] depending on whether it is a text or binary |
| 65 * message. If the message is empty [message] will be [:null:]. | 65 * message. If the message is empty [message] will be [:null:]. |
| 66 */ | 66 */ |
| 67 void set onMessage(void callback(message)); | 67 void set onMessage(void callback(message)); |
| 68 | 68 |
| 69 /** | 69 /** |
| 70 * 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 |
| 71 * closed. [status] indicate the reason for closing. For network | 71 * closed. [status] indicate the reason for closing. For network |
| 72 * errors the value of [status] will be | 72 * errors the value of [status] will be |
| 73 * WebSocketStatus.ABNORMAL_CLOSURE]. | 73 * WebSocketStatus.ABNORMAL_CLOSURE]. In this callbach it is |
| 74 * possible to call [close] if [close] has not already been called. |
| 75 * If [close] has still not been called after the close callback |
| 76 * returns the received close status will automatically be echoed |
| 77 * back to the other end to finish the close handshake. |
| 74 */ | 78 */ |
| 75 void set onClosed(void callback(int status, String reason)); | 79 void set onClosed(void callback(int status, String reason)); |
| 76 | 80 |
| 77 /** | 81 /** |
| 78 * Sends a message. The [message] must be a [:String:] a | 82 * Sends a message. The [message] must be a [:String:] a |
| 79 * [:List<int>:] or [:null:]. | 83 * [:List<int>:] or [:null:]. |
| 80 */ | 84 */ |
| 81 send(Object message); | 85 send(Object message); |
| 82 | 86 |
| 83 /** | 87 /** |
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 289 */ | 293 */ |
| 290 void send(data); | 294 void send(data); |
| 291 } | 295 } |
| 292 | 296 |
| 293 | 297 |
| 294 class WebSocketException implements Exception { | 298 class WebSocketException implements Exception { |
| 295 const WebSocketException([String this.message = ""]); | 299 const WebSocketException([String this.message = ""]); |
| 296 String toString() => "WebSocketException: $message"; | 300 String toString() => "WebSocketException: $message"; |
| 297 final String message; | 301 final String message; |
| 298 } | 302 } |
| OLD | NEW |