
public class JsWebSocket extends JsElementalMixinBase implements WebSocket
CLOSED, CLOSING, CONNECTING, OPENSVG_ZOOMANDPAN_DISABLE, SVG_ZOOMANDPAN_MAGNIFY, SVG_ZOOMANDPAN_UNKNOWN| Modifier | Constructor and Description |
|---|---|
protected |
JsWebSocket() |
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Closes the WebSocket connection or connection attempt, if any.
|
void |
close(int code)
Closes the WebSocket connection or connection attempt, if any.
|
void |
close(int code,
String reason)
Closes the WebSocket connection or connection attempt, if any.
|
String |
getBinaryType()
A string indicating the type of binary data being transmitted by the connection.
|
int |
getBufferedAmount()
The number of bytes of data that have been queued using calls to but not yet transmitted to the network.
|
String |
getExtensions()
The extensions selected by the server.
|
EventListener |
getOnclose()
An event listener to be called when the WebSocket connection's
readyState changes to CLOSED. |
EventListener |
getOnerror()
An event listener to be called when an error occurs.
|
EventListener |
getOnmessage()
An event listener to be called when a message is received from the server.
|
EventListener |
getOnopen()
An event listener to be called when the WebSocket connection's
readyState changes to OPEN; this indicates that the connection is ready to send and receive data. |
String |
getProtocol()
A string indicating the name of the sub-protocol the server selected; this will be one of the strings specified in the
protocols parameter when creating the WebSocket object. |
int |
getReadyState()
The current state of the connection; this is one of the Ready state constants.
|
String |
getUrl()
The URL as resolved by the constructor.
|
String |
getURL() |
boolean |
send(String data)
Transmits data to the server over the WebSocket connection.
|
void |
setBinaryType(String param_binaryType) |
void |
setOnclose(EventListener listener) |
void |
setOnerror(EventListener listener) |
void |
setOnmessage(EventListener listener) |
void |
setOnopen(EventListener listener) |
addEventListener, addEventListener, beginElement, beginElementAt, dispatchEvent, endElement, endElementAt, getAnimatedClassName, getAnimatedHeight, getAnimatedHref, getAnimatedResult, getAnimatedTransform, getAnimatedWidth, getAnimatedX, getAnimatedY, getBBox, getChildElementCount, getCTM, getExternalResourcesRequired, getFarthestViewportElement, getFirstElementChild, getLastElementChild, getNearestViewportElement, getNextElementSibling, getPresentationAttribute, getPreserveAspectRatio, getPreviousElementSibling, getRequiredExtensions, getRequiredFeatures, getScreenCTM, getSvgStyle, getSystemLanguage, getTransformToElement, getViewBox, getXmllang, getXmlspace, getZoomAndPan, hasExtension, querySelector, querySelectorAll, removeEventListener, removeEventListener, setXmllang, setXmlspace, setZoomAndPanat, at, intAt, intAt, length, numberAt, numberAt, setAt, setAt, setAt, setAt, setAt, setAtcast, createArray, createArray, createFunction, createObject, equals, hashCode, toSource, toStringaddEventListener, addEventListener, dispatchEvent, removeEventListener, removeEventListenerintAt, lengthnumberAtpublic final String getBinaryType()
WebSocketBlob
objects are being used or "arraybuffer" if ArrayBuffer objects are being used.getBinaryType in interface WebSocketpublic final void setBinaryType(String param_binaryType)
setBinaryType in interface WebSocketpublic final int getBufferedAmount()
WebSocketgetBufferedAmount in interface WebSocketpublic final String getExtensions()
WebSocketgetExtensions in interface WebSocketpublic final EventListener getOnclose()
WebSocketreadyState changes to CLOSED. The listener receives a CloseEvent named "close".getOnclose in interface WebSocketpublic final void setOnclose(EventListener listener)
setOnclose in interface WebSocketpublic final EventListener getOnerror()
WebSocketgetOnerror in interface WebSocketpublic final void setOnerror(EventListener listener)
setOnerror in interface WebSocketpublic final EventListener getOnmessage()
WebSocketMessageEvent named "message".getOnmessage in interface WebSocketpublic final void setOnmessage(EventListener listener)
setOnmessage in interface WebSocketpublic final EventListener getOnopen()
WebSocketreadyState changes to OPEN; this indicates that the connection is ready to send and receive data. The event is a simple one with the name "open".public final void setOnopen(EventListener listener)
public final String getProtocol()
WebSocketprotocols parameter when creating the WebSocket object.getProtocol in interface WebSocketpublic final int getReadyState()
WebSocketgetReadyState in interface WebSocketpublic final String getUrl()
WebSocketpublic final void close()
WebSocketCloses the WebSocket connection or connection attempt, if any. If the connection is already CLOSED, this method does nothing.
code
Optional
CloseEvent page for permitted values.reason
Optional
INVALID_ACCESS_ERRcode was specified.SYNTAX_ERRreason string is too long or contains unpaired surrogates.public final void close(int code)
WebSocketCloses the WebSocket connection or connection attempt, if any. If the connection is already CLOSED, this method does nothing.
code
Optional
CloseEvent page for permitted values.reason
Optional
INVALID_ACCESS_ERRcode was specified.SYNTAX_ERRreason string is too long or contains unpaired surrogates.public final void close(int code,
String reason)
WebSocketCloses the WebSocket connection or connection attempt, if any. If the connection is already CLOSED, this method does nothing.
code
Optional
CloseEvent page for permitted values.reason
Optional
INVALID_ACCESS_ERRcode was specified.SYNTAX_ERRreason string is too long or contains unpaired surrogates.public final boolean send(String data)
WebSocketTransmits data to the server over the WebSocket connection.
dataINVALID_STATE_ERROPEN.SYNTAX_ERR
Gecko's implementation of the send() method differs somewhat from the specification in Gecko 6.0; Gecko returns a boolean indicating whether or not the connection is still open (and, by extension, that the data was successfully queued or transmitted); this is corrected in Gecko 8.0 (Firefox 8.0 / Thunderbird 8.0 / SeaMonkey 2.5)
. In addition, at this time, Gecko does not support ArrayBuffer or Blob
data types.
Copyright © 2016. All rights reserved.