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.
|
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.
|
int |
getReadyState()
Returns The current state of the connection.
|
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 |
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, getEventHandlerProp, getEventListenersContainer, hasEventHandlers, removeEventListener, setEventHandler, setEventHandlerProp
clone, equivalentValues, get, getBrowserVersion, getDefaultValue, getDomNodeOrDie, getDomNodeOrNull, getPrototype, getScriptableFor, getStartingScope, getWindow, getWindow, getWithPreemption, hasInstance, initParentScope, isReadOnlySettable, makeScriptableFor, setCaseSensitive, setDomNode, setDomNode, setHtmlElement
defineFunctionProperties, defineProperty, getClassName, setClassName, setParentScope
applyDescriptorToAttributeBitset, associateValue, avoidObjectDetection, buildDataDescriptor, callMethod, callMethod, checkPropertyChange, checkPropertyDefinition, defineClass, defineClass, defineClass, defineConst, defineConstProperty, defineOwnProperties, defineOwnProperty, defineOwnProperty, defineProperty, defineProperty, defineProperty, delete, delete, deleteProperty, deleteProperty, ensureScriptable, ensureScriptableObject, get, get, getAllIds, getArrayPrototype, getAssociatedValue, getAttributes, getAttributes, getAttributes, getAttributes, getClassPrototype, getDefaultValue, getExternalArrayData, getExternalArrayLength, getFunctionPrototype, getGetterOrSetter, getIds, getObjectPrototype, getOwnPropertyDescriptor, getParentScope, getProperty, getProperty, getPropertyIds, getPrototype, getSlot, getTopLevelScope, getTopScopeValue, getTypedProperty, getTypedProperty, getTypeOf, has, has, hasProperty, hasProperty, isAccessorDescriptor, isConst, isDataDescriptor, isEmpty, isExtensible, isFalse, isGenericDescriptor, isGetterOrSetter, isSealed, isTrue, preventExtensions, put, put, putConst, putConstProperty, putProperty, putProperty, redefineProperty, sameValue, sealObject, setAttributes, setAttributes, setAttributes, setAttributes, 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 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 void close() throws Exception
close
in interface AutoCloseable
Exception
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–2017 Gargoyle Software Inc.. All rights reserved.