public class WebSocket extends EventTarget implements AutoCloseable
WebSocket
.org.htmlunit.corejs.javascript.ScriptableObject.KeyComparator
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.
|
CONST, DONTENUM, EMPTY, PERMANENT, READONLY, UNINITIALIZED_CONST
NOT_FOUND
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() |
org.htmlunit.corejs.javascript.Function |
getOnclose()
Returns the event handler that fires on close.
|
org.htmlunit.corejs.javascript.Function |
getOnerror()
Returns the event handler that fires on error.
|
org.htmlunit.corejs.javascript.Function |
getOnmessage()
Returns the event handler that fires on message.
|
org.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 org.htmlunit.corejs.javascript.Scriptable |
jsConstructor(org.htmlunit.corejs.javascript.Context cx,
org.htmlunit.corejs.javascript.Scriptable scope,
Object[] args,
org.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(org.htmlunit.corejs.javascript.Function closeHandler)
Sets the event handler that fires on close.
|
void |
setOnerror(org.htmlunit.corejs.javascript.Function errorHandler)
Sets the event handler that fires on error.
|
void |
setOnmessage(org.htmlunit.corejs.javascript.Function messageHandler)
Sets the event handler that fires on message.
|
void |
setOnopen(org.htmlunit.corejs.javascript.Function openHandler)
Sets the event handler that fires on open.
|
addEventListener, clearEventListenersContainer, dispatchEvent, executeEventLocally, fireEvent, getEventHandler, getEventListenersContainer, hasEventHandlers, isEventHandlerOnWindow, jsConstructor, removeEventListener, setEventHandler
clone, equivalentValues, get, getBrowserVersion, getClassName, getDefaultValue, getDomNodeOrDie, getDomNodeOrNull, getPrototype, getScriptableFor, getWindow, getWindow, getWindowFromTopCallScope, getWithPreemption, has, hasInstance, initParentScope, makeScriptableFor, put, setClassName, setDomNode, setDomNode, setParentScope, setupPromise, setupRejectedPromise
applyDescriptorToAttributeBitset, associateValue, avoidObjectDetection, buildDataDescriptor, callMethod, callMethod, checkPropertyChange, checkPropertyDefinition, defineClass, defineClass, defineClass, defineConst, defineConstProperty, defineFunctionProperties, defineOwnProperties, defineOwnProperty, defineOwnProperty, defineProperty, defineProperty, defineProperty, defineProperty, defineProperty, defineProperty, defineProperty, defineProperty, delete, delete, delete, deleteProperty, deleteProperty, deleteProperty, ensureScriptable, ensureScriptableObject, ensureSymbolScriptable, get, get, get, getAllIds, getArrayPrototype, getAssociatedValue, getAttributes, getAttributes, getAttributes, getAttributes, getAttributes, getClassPrototype, getDefaultValue, getExternalArrayData, getExternalArrayLength, getFunctionPrototype, getGeneratorFunctionPrototype, getGetterOrSetter, getGetterOrSetter, getIds, getObjectPrototype, getOwnPropertyDescriptor, getParentScope, getProperty, getProperty, getProperty, getPropertyIds, getPrototype, getTopLevelScope, getTopScopeValue, getTypedProperty, getTypedProperty, getTypeOf, has, has, hasProperty, hasProperty, hasProperty, isAccessorDescriptor, isConst, isDataDescriptor, isEmpty, isExtensible, isFalse, isGenericDescriptor, isGetterOrSetter, isSealed, isTrue, preventExtensions, put, put, putConst, putConstProperty, putProperty, putProperty, putProperty, querySlot, redefineProperty, sameValue, sealObject, setAttributes, setAttributes, setAttributes, setAttributes, setAttributes, setCommonDescriptorProperties, setExternalArrayData, setGetterOrSetter, setPrototype, size
public static final int CONNECTING
public static final int OPEN
public static final int CLOSING
public static final int CLOSED
public static org.htmlunit.corejs.javascript.Scriptable jsConstructor(org.htmlunit.corejs.javascript.Context cx, org.htmlunit.corejs.javascript.Scriptable scope, Object[] args, org.htmlunit.corejs.javascript.Function ctorObj, boolean inNewExpr)
cx
- the current contextscope
- the scopeargs
- the arguments to the WebSocket constructorctorObj
- the function objectinNewExpr
- Is new or notpublic org.htmlunit.corejs.javascript.Function getOnclose()
public void setOnclose(org.htmlunit.corejs.javascript.Function closeHandler)
closeHandler
- the event handler that fires on closepublic org.htmlunit.corejs.javascript.Function getOnerror()
public void setOnerror(org.htmlunit.corejs.javascript.Function errorHandler)
errorHandler
- the event handler that fires on errorpublic org.htmlunit.corejs.javascript.Function getOnmessage()
public void setOnmessage(org.htmlunit.corejs.javascript.Function messageHandler)
messageHandler
- the event handler that fires on messagepublic org.htmlunit.corejs.javascript.Function getOnopen()
public void setOnopen(org.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 AutoCloseable
IOException
public 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–2024 Gargoyle Software Inc.. All rights reserved.