WebSocket Interface
Alternative web socket client interface. This interface is compliant with the W3C browser API for web sockets specified in http://dev.w3.org/html5/websockets/.
Constructors
Code new WebSocket(String url, [protocols]) #
Create a new web socket connection. The URL supplied in
url
must use the scheme ws
. The
protocols argument is either a
String
or List<String>
specifying the subprotocols the
client is willing to speak.
WebSocket(String url, [protocols]);
Static Fields
Methods
Code int get bufferedAmount() #
Returns the number of bytes currently buffered for transmission.
int get bufferedAmount();
Code void close(int code, String reason) #
Closes the web socket connection.
void close(int code, String reason);
Code String get extensions() #
The extensions property is initially the empty string. After the web socket connection is established this string reflects the extensions used by the server.
String get extensions();
Code void set onclose(void callback(CloseEvent event)) #
Sets the callback to be called when the web socket connection is closed.
void set onclose(void callback(CloseEvent event));
Code void set onerror(void callback(e)) #
Sets the callback to be called when the web socket connection encountered an error.
void set onerror(void callback(e));
Code void set onmessage(void callback(MessageEvent event)) #
Sets the callback to be called when a message have been received.
void set onmessage(void callback(MessageEvent event));
Code void set onopen(void callback()) #
Sets the callback to be called when a web socket connection has been established.
void set onopen(void callback());
Code String get protocol() #
The protocol property is initially the empty string. After the
web socket connection is established the value is the subprotocol
selected by the server. If no subprotocol is negotiated the
value will remain null
.
String get protocol();
Code void send(data) #
Sends data on the web socket connection. The data in
data must
be either a String
or List<int>
holding bytes.
void send(data);