public class WebSocket extends EventTarget implements AutoCloseable
WebSocket.| Modifier and Type | Field and Description |
|---|---|
static int |
CLOSED
The connection has been closed or could not be opened.
|
static int |
CLOSING
The connection is going through the closing handshake.
|
static int |
CONNECTING
The connection has not yet been established.
|
static int |
OPEN
The WebSocket connection is established and communication is possible.
|
| Constructor and Description |
|---|
WebSocket()
Creates a new instance.
|
| Modifier and Type | Method and Description |
|---|---|
void |
close() |
void |
close(Object code,
Object reason)
Closes the WebSocket connection or connection attempt, if any.
|
String |
getBinaryType() |
long |
getBufferedAmount() |
net.sourceforge.htmlunit.corejs.javascript.Function |
getOnclose()
Returns the event handler that fires on close.
|
net.sourceforge.htmlunit.corejs.javascript.Function |
getOnerror()
Returns the event handler that fires on error.
|
net.sourceforge.htmlunit.corejs.javascript.Function |
getOnmessage()
Returns the event handler that fires on message.
|
net.sourceforge.htmlunit.corejs.javascript.Function |
getOnopen()
Returns the event handler that fires on open.
|
String |
getProtocol() |
int |
getReadyState()
Returns The current state of the connection.
|
String |
getUrl() |
static net.sourceforge.htmlunit.corejs.javascript.Scriptable |
jsConstructor(net.sourceforge.htmlunit.corejs.javascript.Context cx,
Object[] args,
net.sourceforge.htmlunit.corejs.javascript.Function ctorObj,
boolean inNewExpr)
JavaScript constructor.
|
void |
send(Object content)
Transmits data to the server over the WebSocket connection.
|
void |
setBinaryType(String type)
Sets the used binary type.
|
void |
setOnclose(net.sourceforge.htmlunit.corejs.javascript.Function closeHandler)
Sets the event handler that fires on close.
|
void |
setOnerror(net.sourceforge.htmlunit.corejs.javascript.Function errorHandler)
Sets the event handler that fires on error.
|
void |
setOnmessage(net.sourceforge.htmlunit.corejs.javascript.Function messageHandler)
Sets the event handler that fires on message.
|
void |
setOnopen(net.sourceforge.htmlunit.corejs.javascript.Function openHandler)
Sets the event handler that fires on open.
|
addEventListener, clearEventListenersContainer, dispatchEvent, executeEventLocally, fireEvent, getEventHandler, getEventListenersContainer, hasEventHandlers, isEventHandlerOnWindow, removeEventListener, setEventHandlerclone, equivalentValues, get, getBrowserVersion, getDefaultValue, getDomNodeOrDie, getDomNodeOrNull, getPrototype, getScriptableFor, getStartingScope, getWindow, getWindow, getWithPreemption, has, hasInstance, initParentScope, makeScriptableFor, setCaseSensitive, setDomNode, setDomNode, setHtmlElementdefineFunctionProperties, defineProperty, getClassName, put, setClassName, setParentScopeapplyDescriptorToAttributeBitset, associateValue, avoidObjectDetection, buildDataDescriptor, callMethod, callMethod, checkPropertyChange, checkPropertyDefinition, defineClass, defineClass, defineClass, defineConst, defineConstProperty, defineOwnProperties, defineOwnProperty, defineOwnProperty, defineProperty, defineProperty, defineProperty, defineProperty, delete, delete, delete, deleteProperty, deleteProperty, ensureScriptable, ensureScriptableObject, ensureSymbolScriptable, get, get, get, getAllIds, getArrayPrototype, getAssociatedValue, getAttributes, getAttributes, getAttributes, getAttributes, getAttributes, getClassPrototype, getDefaultValue, getExternalArrayData, getExternalArrayLength, getFunctionPrototype, getGetterOrSetter, getIds, getObjectPrototype, getOwnPropertyDescriptor, getParentScope, getProperty, getProperty, getProperty, getPropertyIds, getPrototype, getSlot, getTopLevelScope, getTopScopeValue, getTypedProperty, getTypedProperty, getTypeOf, has, has, hasProperty, hasProperty, hasProperty, isAccessorDescriptor, isConst, isDataDescriptor, isEmpty, isExtensible, isFalse, isGenericDescriptor, isGetterOrSetter, isReadOnlySettable, isSealed, isTrue, preventExtensions, put, put, putConst, putConstProperty, putProperty, putProperty, putProperty, redefineProperty, sameValue, sealObject, setAttributes, setAttributes, setAttributes, setAttributes, setAttributes, setExternalArrayData, setGetterOrSetter, setPrototype, sizepublic static final int CONNECTING
public static final int OPEN
public static final int CLOSING
public static final int CLOSED
public static net.sourceforge.htmlunit.corejs.javascript.Scriptable jsConstructor(net.sourceforge.htmlunit.corejs.javascript.Context cx,
Object[] args,
net.sourceforge.htmlunit.corejs.javascript.Function ctorObj,
boolean inNewExpr)
cx - the current contextargs - the arguments to the WebSocket constructorctorObj - the function objectinNewExpr - Is new or notpublic net.sourceforge.htmlunit.corejs.javascript.Function getOnclose()
public void setOnclose(net.sourceforge.htmlunit.corejs.javascript.Function closeHandler)
closeHandler - the event handler that fires on closepublic net.sourceforge.htmlunit.corejs.javascript.Function getOnerror()
public void setOnerror(net.sourceforge.htmlunit.corejs.javascript.Function errorHandler)
errorHandler - the event handler that fires on errorpublic net.sourceforge.htmlunit.corejs.javascript.Function getOnmessage()
public void setOnmessage(net.sourceforge.htmlunit.corejs.javascript.Function messageHandler)
messageHandler - the event handler that fires on messagepublic net.sourceforge.htmlunit.corejs.javascript.Function getOnopen()
public void setOnopen(net.sourceforge.htmlunit.corejs.javascript.Function openHandler)
openHandler - the event handler that fires on openpublic int getReadyState()
CONNECTING, OPEN,
CLOSING or CLOSED.public String getUrl()
public String getProtocol()
public long getBufferedAmount()
public String getBinaryType()
public void setBinaryType(String type)
type - the typepublic void close()
throws IOException
close in interface AutoCloseableIOExceptionpublic void close(Object code, Object reason)
CLOSED, this method does nothing.code - A numeric value indicating the status code explaining why the connection is being closedreason - A human-readable string explaining why the connection is closingpublic void send(Object content)
content - the body of the message being sent with the requestCopyright © 2002–2020 Gargoyle Software Inc.. All rights reserved.