public class JsWebSocket extends JsElementalMixinBase implements WebSocket
CLOSED, CLOSING, CONNECTING, OPEN
SVG_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, setZoomAndPan
at, at, intAt, intAt, length, numberAt, numberAt, setAt, setAt, setAt, setAt, setAt, setAt
cast, createArray, createArray, createFunction, createObject, equals, hashCode, toSource, toString
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
addEventListener, addEventListener, dispatchEvent, removeEventListener, removeEventListener
intAt, length
numberAt
public final String getBinaryType()
WebSocket
Blob
objects are being used or "arraybuffer" if ArrayBuffer
objects are being used.getBinaryType
in interface WebSocket
public final void setBinaryType(String param_binaryType)
setBinaryType
in interface WebSocket
public final int getBufferedAmount()
WebSocket
getBufferedAmount
in interface WebSocket
public final String getExtensions()
WebSocket
getExtensions
in interface WebSocket
public final EventListener getOnclose()
WebSocket
readyState
changes to CLOSED
. The listener receives a CloseEvent
named "close".getOnclose
in interface WebSocket
public final void setOnclose(EventListener listener)
setOnclose
in interface WebSocket
public final EventListener getOnerror()
WebSocket
getOnerror
in interface WebSocket
public final void setOnerror(EventListener listener)
setOnerror
in interface WebSocket
public final EventListener getOnmessage()
WebSocket
MessageEvent
named "message".getOnmessage
in interface WebSocket
public final void setOnmessage(EventListener listener)
setOnmessage
in interface WebSocket
public final EventListener getOnopen()
WebSocket
readyState
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()
WebSocket
protocols
parameter when creating the WebSocket object.getProtocol
in interface WebSocket
public final int getReadyState()
WebSocket
getReadyState
in interface WebSocket
public final String getUrl()
WebSocket
public final void close()
WebSocket
Closes 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_ERR
code
was specified.SYNTAX_ERR
reason
string is too long or contains unpaired surrogates.public final void close(int code)
WebSocket
Closes 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_ERR
code
was specified.SYNTAX_ERR
reason
string is too long or contains unpaired surrogates.public final void close(int code, String reason)
WebSocket
Closes 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_ERR
code
was specified.SYNTAX_ERR
reason
string is too long or contains unpaired surrogates.public final boolean send(String data)
WebSocket
Transmits data to the server over the WebSocket connection.
data
INVALID_STATE_ERR
OPEN
.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 © 2018. All rights reserved.