Dart API Referencedart:ioWebSocketConnection

WebSocketConnection abstract class

Server web socket connection.

abstract class WebSocketConnection {
  /**
   * Sets the callback to be called when a message have been
   * received. The type on [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. [status] indicate the reason for closing. For network
   * errors the value of [status] will be
   * WebSocketStatus.ABNORMAL_CLOSURE]. In this callbach it is
   * possible to call [close] if [close] has not already been called.
   * If [close] has still not been called after the close callback
   * returns the received close status will automatically be echoed
   * back to the other end to finish the close handshake.
   */
  void set onClosed(void callback(int status, String reason));

  /**
   * Sends a message. The [message] must be a [:String:] a
   * [:List<int>:] or [:null:].
   */
  send(Object message);

  /**
   * Close the web socket connection. The default value for [status]
   * and [reason] are [:null:].
   */
  close([int status, String reason]);

  /**
   * WebSocketConnection is hashable.
   */
  int get hashCode;
}

Properties

final int hashCode #

WebSocketConnection is hashable.

int get hashCode;

void set onClosed(void callback(int status, String reason)) #

Sets the callback to be called when the web socket connection is closed. status indicate the reason for closing. For network errors the value of status will be WebSocketStatus.ABNORMAL_CLOSURE]. In this callbach it is possible to call close if close has not already been called. If close has still not been called after the close callback returns the received close status will automatically be echoed back to the other end to finish the close handshake.

void set onClosed(void callback(int status, String reason));

void set onMessage(void callback(message)) #

Sets the callback to be called when a message have been received. The type on 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));

Methods

close([int status, String reason]) #

Close the web socket connection. The default value for status and reason are null.

close([int status, String reason]);

send(Object message) #

Sends a message. The message must be a String a List<int> or null.

send(Object message);