@Generated(value="org.realityforge.webtack")
@JsType(isNative=true,
namespace="<global>",
name="WebSocket")
public class WebSocket
extends EventTarget
| Modifier and Type | Field and Description |
|---|---|
@JsNonNull java.lang.String |
binaryType
The WebSocket.binaryType property returns the type of binary data being transmitted by the connection.
|
static int |
CLOSED |
static int |
CLOSING |
static int |
CONNECTING |
@JsNullable CloseEventHandler |
onclose
The WebSocket.onclose property is an EventHandler that is called when the WebSocket connection's readyState changes to CLOSED.
|
@JsNullable EventHandler |
onerror
The WebSocket interface's onerror event handler property is a function which gets called when an error occurs on the WebSocket.
|
@JsNullable MessageEventHandler |
onmessage
The WebSocket.onmessage property is an EventHandler that is called when a message is received from the server.
|
@JsNullable EventHandler |
onopen
The WebSocket.onopen property is an EventHandler that is called when the WebSocket connection's readyState changes to 1; this indicates that the connection is ready to send and receive data.
|
static int |
OPEN |
| Constructor and Description |
|---|
WebSocket(java.lang.String url)
The WebSocket() constructor returns a new WebSocket object.
|
WebSocket(java.lang.String url,
JsArray<java.lang.String> protocols)
The WebSocket() constructor returns a new WebSocket object.
|
WebSocket(java.lang.String url,
java.lang.String protocols)
The WebSocket() constructor returns a new WebSocket object.
|
WebSocket(java.lang.String url,
java.lang.String[] protocols)
The WebSocket() constructor returns a new WebSocket object.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addCloseListener(CloseEventListener callback) |
void |
addCloseListener(CloseEventListener callback,
AddEventListenerOptions options) |
void |
addCloseListener(CloseEventListener callback,
boolean useCapture) |
void |
addErrorListener(EventListener callback) |
void |
addErrorListener(EventListener callback,
AddEventListenerOptions options) |
void |
addErrorListener(EventListener callback,
boolean useCapture) |
void |
addMessageListener(MessageEventListener callback) |
void |
addMessageListener(MessageEventListener callback,
AddEventListenerOptions options) |
void |
addMessageListener(MessageEventListener callback,
boolean useCapture) |
void |
addOpenListener(EventListener callback) |
void |
addOpenListener(EventListener callback,
AddEventListenerOptions options) |
void |
addOpenListener(EventListener callback,
boolean useCapture) |
int |
bufferedAmount()
The WebSocket.bufferedAmount read-only property returns the number of bytes of data that have been queued using calls to send() but not yet transmitted to the network.
|
void |
close()
The WebSocket.close() method closes the WebSocket connection or connection attempt, if any.
|
void |
close(int code)
The WebSocket.close() method closes the WebSocket connection or connection attempt, if any.
|
void |
close(int code,
java.lang.String reason)
The WebSocket.close() method closes the WebSocket connection or connection attempt, if any.
|
java.lang.String |
extensions()
The WebSocket.extensions read-only property returns the extensions selected by the server.
|
java.lang.String |
protocol()
The WebSocket.protocol read-only property returns 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, or the empty string if no connection is established.
|
int |
readyState()
The WebSocket.readyState read-only property returns the current state of the WebSocket connection.
|
void |
removeCloseListener(CloseEventListener callback) |
void |
removeCloseListener(CloseEventListener callback,
boolean useCapture) |
void |
removeCloseListener(CloseEventListener callback,
EventListenerOptions options) |
void |
removeErrorListener(EventListener callback) |
void |
removeErrorListener(EventListener callback,
boolean useCapture) |
void |
removeErrorListener(EventListener callback,
EventListenerOptions options) |
void |
removeMessageListener(MessageEventListener callback) |
void |
removeMessageListener(MessageEventListener callback,
boolean useCapture) |
void |
removeMessageListener(MessageEventListener callback,
EventListenerOptions options) |
void |
removeOpenListener(EventListener callback) |
void |
removeOpenListener(EventListener callback,
boolean useCapture) |
void |
removeOpenListener(EventListener callback,
EventListenerOptions options) |
void |
send(ArrayBuffer data)
The WebSocket.send() method enqueues the specified data to be transmitted to the server over the WebSocket connection, increasing the value of bufferedAmount by the number of bytes needed to contain the data.
|
void |
send(ArrayBufferView data)
The WebSocket.send() method enqueues the specified data to be transmitted to the server over the WebSocket connection, increasing the value of bufferedAmount by the number of bytes needed to contain the data.
|
void |
send(Blob data)
The WebSocket.send() method enqueues the specified data to be transmitted to the server over the WebSocket connection, increasing the value of bufferedAmount by the number of bytes needed to contain the data.
|
void |
send(java.lang.String data)
The WebSocket.send() method enqueues the specified data to be transmitted to the server over the WebSocket connection, increasing the value of bufferedAmount by the number of bytes needed to contain the data.
|
java.lang.String |
url()
The WebSocket.url read-only property returns the absolute URL of the WebSocket as resolved by the constructor.
|
addEventListener, addEventListener, addEventListener, dispatchEvent, removeEventListener, removeEventListener, removeEventListenerassign, create, create, defineProperties, defineProperty, defineProperty, entries, freeze, fromEntries, getOwnPropertyDescriptor, getOwnPropertyDescriptor, getOwnPropertyDescriptors, getOwnPropertyNames, getOwnPropertySymbols, getPrototypeOf, hasOwnProperty, hasOwnProperty, is, isExtensible, isFrozen, isPrototypeOf, isSealed, keys, preventExtensions, propertyIsEnumerable, seal, setPrototypeOf, toString_, valueOf_, values@JsOverlay public static final int CLOSED
@JsOverlay public static final int CLOSING
@JsOverlay public static final int CONNECTING
@JsOverlay public static final int OPEN
@BinaryType public @JsNonNull java.lang.String binaryType
public @JsNullable CloseEventHandler onclose
public @JsNullable EventHandler onerror
public @JsNullable MessageEventHandler onmessage
public @JsNullable EventHandler onopen
public WebSocket(@Nonnull
java.lang.String url,
@Nonnull
java.lang.String protocols)
public WebSocket(@Nonnull
java.lang.String url,
@Nonnull
JsArray<java.lang.String> protocols)
public WebSocket(@Nonnull
java.lang.String url,
@Nonnull
java.lang.String[] protocols)
public WebSocket(@Nonnull
java.lang.String url)
@JsProperty(name="bufferedAmount") public int bufferedAmount()
@JsProperty(name="extensions") @Nonnull public java.lang.String extensions()
@JsProperty(name="protocol") @Nonnull public java.lang.String protocol()
@JsProperty(name="readyState") @WebSocketReadyState public int readyState()
@JsProperty(name="url") @Nonnull public java.lang.String url()
public void close(int code,
@Nonnull
java.lang.String reason)
public void close(int code)
public void close()
public void send(@Nonnull
java.lang.String data)
public void send(@Nonnull
Blob data)
public void send(@Nonnull
ArrayBuffer data)
public void send(@Nonnull
ArrayBufferView data)
@JsOverlay
public final void addCloseListener(@Nonnull
CloseEventListener callback,
@Nonnull
AddEventListenerOptions options)
@JsOverlay
public final void addCloseListener(@Nonnull
CloseEventListener callback,
boolean useCapture)
@JsOverlay
public final void addCloseListener(@Nonnull
CloseEventListener callback)
@JsOverlay
public final void removeCloseListener(@Nonnull
CloseEventListener callback,
@Nonnull
EventListenerOptions options)
@JsOverlay
public final void removeCloseListener(@Nonnull
CloseEventListener callback,
boolean useCapture)
@JsOverlay
public final void removeCloseListener(@Nonnull
CloseEventListener callback)
@JsOverlay
public final void addMessageListener(@Nonnull
MessageEventListener callback,
@Nonnull
AddEventListenerOptions options)
@JsOverlay
public final void addMessageListener(@Nonnull
MessageEventListener callback,
boolean useCapture)
@JsOverlay
public final void addMessageListener(@Nonnull
MessageEventListener callback)
@JsOverlay
public final void removeMessageListener(@Nonnull
MessageEventListener callback,
@Nonnull
EventListenerOptions options)
@JsOverlay
public final void removeMessageListener(@Nonnull
MessageEventListener callback,
boolean useCapture)
@JsOverlay
public final void removeMessageListener(@Nonnull
MessageEventListener callback)
@JsOverlay
public final void addErrorListener(@Nonnull
EventListener callback,
@Nonnull
AddEventListenerOptions options)
@JsOverlay
public final void addErrorListener(@Nonnull
EventListener callback,
boolean useCapture)
@JsOverlay
public final void addErrorListener(@Nonnull
EventListener callback)
@JsOverlay
public final void removeErrorListener(@Nonnull
EventListener callback,
@Nonnull
EventListenerOptions options)
@JsOverlay
public final void removeErrorListener(@Nonnull
EventListener callback,
boolean useCapture)
@JsOverlay
public final void removeErrorListener(@Nonnull
EventListener callback)
@JsOverlay
public final void addOpenListener(@Nonnull
EventListener callback,
@Nonnull
AddEventListenerOptions options)
@JsOverlay
public final void addOpenListener(@Nonnull
EventListener callback,
boolean useCapture)
@JsOverlay
public final void addOpenListener(@Nonnull
EventListener callback)
@JsOverlay
public final void removeOpenListener(@Nonnull
EventListener callback,
@Nonnull
EventListenerOptions options)
@JsOverlay
public final void removeOpenListener(@Nonnull
EventListener callback,
boolean useCapture)
@JsOverlay
public final void removeOpenListener(@Nonnull
EventListener callback)