| Index: runtime/bin/websocket.dart
|
| diff --git a/runtime/bin/websocket.dart b/runtime/bin/websocket.dart
|
| index f7a36f8fcfde41fe3e50c8a29e0e99ba28968bc9..cca6747b4ce60edb947764cd99b43ba3015905d9 100644
|
| --- a/runtime/bin/websocket.dart
|
| +++ b/runtime/bin/websocket.dart
|
| @@ -34,7 +34,7 @@ interface WebSocketHandler default _WebSocketHandler {
|
|
|
|
|
| /**
|
| - * Web socket connection.
|
| + * Server web socket connection.
|
| */
|
| interface WebSocketConnection {
|
| /**
|
| @@ -71,6 +71,76 @@ interface WebSocketConnection {
|
| }
|
|
|
|
|
| +/**
|
| + * Client web socket connection.
|
| + */
|
| +interface WebSocketClientConnection default _WebSocketClientConnection {
|
| + /**
|
| + * Creates a new web socket client connection based on a HTTP client
|
| + * connection. The HTTP client connection must be freshly opened.
|
| + */
|
| + WebSocketClientConnection(HttpClientConnection conn,
|
| + [List<String> protocols]);
|
| +
|
| + /**
|
| + * Sets the callback to be called when the request object for the
|
| + * opening handshake request is ready. This callback can be used if
|
| + * one need to add additional headers to the opening handshake
|
| + * request.
|
| + */
|
| + void set onRequest(void callback(HttpClientRequest request));
|
| +
|
| + /**
|
| + * Sets the callback to be called when a web socket connection has
|
| + * been established.
|
| + */
|
| + void set onOpen(void callback());
|
| +
|
| + /**
|
| + * Sets the callback to be called when a message have been
|
| + * received. The type of [message] is either [:String:] or
|
| + * [:List<int>:] depending on whether it is a text or binary
|
| + * message. If the message is empty [message] will be [:null:].
|
| + */
|
| + void set onMessage(void callback(message));
|
| +
|
| + /**
|
| + * Sets the callback to be called when the web socket connection is
|
| + * closed.
|
| + */
|
| + void set onClosed(void callback(int status, String reason));
|
| +
|
| + /**
|
| + * Sets the callback to be called when the response object for the
|
| + * opening handshake did not cause a web socket connection
|
| + * upgrade. This will be called in case the response status code is
|
| + * not 101 (Switching Protocols). If this callback is not set the
|
| + * [:onError:] callback will be called if the server did not upgrade
|
| + * the connection.
|
| + */
|
| + void set onNoUpgrade(void callback(HttpClientResponse response));
|
| +
|
| + /**
|
| + * Sets the callback to be called when the web socket connection
|
| + * encountered an error.
|
| + */
|
| + void set onError(void callback(e));
|
| +
|
| + /**
|
| + * Sends a message. The [message] must be a [:String:] or a
|
| + * [:List<int>:]. To send an empty message use either an empty
|
| + * [:String:] or an empty [:List<int>:]. [:null:] cannot be used.
|
| + */
|
| + send(message);
|
| +
|
| + /**
|
| + * Close the web socket connection. The default value for [status]
|
| + * and [reason] are [:null:].
|
| + */
|
| + close([int status, String reason]);
|
| +}
|
| +
|
| +
|
| class WebSocketException implements Exception {
|
| const WebSocketException([String this.message = ""]);
|
| String toString() => "WebSocketException: $message";
|
|
|