| 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 part of dart.io; | 5 part of dart.io; |
| 6 | 6 |
| 7 /** | 7 /** |
| 8 * Web socket status codes used when closing a web socket connection. | 8 * Web socket status codes used when closing a web socket connection. |
| 9 */ | 9 */ |
| 10 abstract class WebSocketStatus { | 10 abstract class WebSocketStatus { |
| (...skipping 29 matching lines...) Expand all Loading... |
| 40 * | 40 * |
| 41 * This transformer strives to implement web sockets as specified by RFC6455. | 41 * This transformer strives to implement web sockets as specified by RFC6455. |
| 42 */ | 42 */ |
| 43 abstract class WebSocketTransformer | 43 abstract class WebSocketTransformer |
| 44 implements StreamTransformer<HttpRequest, WebSocket> { | 44 implements StreamTransformer<HttpRequest, WebSocket> { |
| 45 factory WebSocketTransformer() => new _WebSocketTransformerImpl(); | 45 factory WebSocketTransformer() => new _WebSocketTransformerImpl(); |
| 46 } | 46 } |
| 47 | 47 |
| 48 | 48 |
| 49 /** | 49 /** |
| 50 * Base class for the events generated by the W3C complient browser | 50 * Base class for the events generated by the [WebSocket] stream. |
| 51 * API for web sockets. | |
| 52 */ | 51 */ |
| 53 abstract class Event { } | 52 abstract class Event { } |
| 54 | 53 |
| 55 /** | 54 /** |
| 56 * Event delivered when there is data on a web socket connection. | 55 * Event delivered when there is data on a web socket connection. |
| 57 */ | 56 */ |
| 58 abstract class MessageEvent extends Event { | 57 abstract class MessageEvent extends Event { |
| 59 /** | 58 /** |
| 60 * The type of [message] is either [:String:] or [:List<int>:] | 59 * The type of [message] is either [:String:] or [:List<int>:] |
| 61 * depending on whether it is a text or binary message. If the | 60 * depending on whether it is a text or binary message. If the |
| (...skipping 22 matching lines...) Expand all Loading... |
| 84 | 83 |
| 85 /** | 84 /** |
| 86 * Returns the web socket connection close reason provided by the | 85 * Returns the web socket connection close reason provided by the |
| 87 * server. | 86 * server. |
| 88 */ | 87 */ |
| 89 String get reason; | 88 String get reason; |
| 90 } | 89 } |
| 91 | 90 |
| 92 | 91 |
| 93 /** | 92 /** |
| 94 * Alternative web socket client interface. This interface is compliant | 93 * A client or server web socket connection. This interface is compliant |
| 95 * with the W3C browser API for web sockets specified in | 94 * with the W3C browser API for web sockets specified in |
| 96 * http://dev.w3.org/html5/websockets/. | 95 * http://dev.w3.org/html5/websockets/. |
| 97 */ | 96 */ |
| 98 abstract class WebSocket implements Stream<Event> { | 97 abstract class WebSocket implements Stream<Event> { |
| 99 /** | 98 /** |
| 100 * Possible states of the connection. | 99 * Possible states of the connection. |
| 101 */ | 100 */ |
| 102 static const int CONNECTING = 0; | 101 static const int CONNECTING = 0; |
| 103 static const int OPEN = 1; | 102 static const int OPEN = 1; |
| 104 static const int CLOSING = 2; | 103 static const int CLOSING = 2; |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 149 */ | 148 */ |
| 150 void send(data); | 149 void send(data); |
| 151 } | 150 } |
| 152 | 151 |
| 153 | 152 |
| 154 class WebSocketException implements Exception { | 153 class WebSocketException implements Exception { |
| 155 const WebSocketException([String this.message = ""]); | 154 const WebSocketException([String this.message = ""]); |
| 156 String toString() => "WebSocketException: $message"; | 155 String toString() => "WebSocketException: $message"; |
| 157 final String message; | 156 final String message; |
| 158 } | 157 } |
| OLD | NEW |