public interface WebSocket
WebSocket class represents websocket connections in the page.| Modifier and Type | Interface and Description |
|---|---|
static class |
WebSocket.WaitForFrameReceivedOptions |
static class |
WebSocket.WaitForFrameSentOptions |
| Modifier and Type | Method and Description |
|---|---|
boolean |
isClosed()
Indicates that the web socket has been closed.
|
void |
offClose(Consumer<WebSocket> handler)
Removes handler that was previously added with
onClose(handler). |
void |
offFrameReceived(Consumer<WebSocketFrame> handler)
Removes handler that was previously added with
onFrameReceived(handler). |
void |
offFrameSent(Consumer<WebSocketFrame> handler)
Removes handler that was previously added with
onFrameSent(handler). |
void |
offSocketError(Consumer<String> handler)
Removes handler that was previously added with
onSocketError(handler). |
void |
onClose(Consumer<WebSocket> handler)
Fired when the websocket closes.
|
void |
onFrameReceived(Consumer<WebSocketFrame> handler)
Fired when the websocket receives a frame.
|
void |
onFrameSent(Consumer<WebSocketFrame> handler)
Fired when the websocket sends a frame.
|
void |
onSocketError(Consumer<String> handler)
Fired when the websocket has an error.
|
String |
url()
Contains the URL of the WebSocket.
|
default WebSocketFrame |
waitForFrameReceived(Runnable callback)
Performs action and waits for a frame to be sent.
|
WebSocketFrame |
waitForFrameReceived(WebSocket.WaitForFrameReceivedOptions options,
Runnable callback)
Performs action and waits for a frame to be sent.
|
default WebSocketFrame |
waitForFrameSent(Runnable callback)
Performs action and waits for a frame to be sent.
|
WebSocketFrame |
waitForFrameSent(WebSocket.WaitForFrameSentOptions options,
Runnable callback)
Performs action and waits for a frame to be sent.
|
void offClose(Consumer<WebSocket> handler)
onClose(handler).void onFrameReceived(Consumer<WebSocketFrame> handler)
void offFrameReceived(Consumer<WebSocketFrame> handler)
onFrameReceived(handler).void onFrameSent(Consumer<WebSocketFrame> handler)
void offFrameSent(Consumer<WebSocketFrame> handler)
onFrameSent(handler).void offSocketError(Consumer<String> handler)
onSocketError(handler).boolean isClosed()
String url()
default WebSocketFrame waitForFrameReceived(Runnable callback)
WebSocketFrame value into the
predicate function and waits for predicate(webSocketFrame) to return a truthy value. Will throw an error if the
WebSocket or Page is closed before the frame is received.callback - Callback that performs the action triggering the event.WebSocketFrame waitForFrameReceived(WebSocket.WaitForFrameReceivedOptions options, Runnable callback)
WebSocketFrame value into the
predicate function and waits for predicate(webSocketFrame) to return a truthy value. Will throw an error if the
WebSocket or Page is closed before the frame is received.callback - Callback that performs the action triggering the event.default WebSocketFrame waitForFrameSent(Runnable callback)
WebSocketFrame value into the
predicate function and waits for predicate(webSocketFrame) to return a truthy value. Will throw an error if the
WebSocket or Page is closed before the frame is sent.callback - Callback that performs the action triggering the event.WebSocketFrame waitForFrameSent(WebSocket.WaitForFrameSentOptions options, Runnable callback)
WebSocketFrame value into the
predicate function and waits for predicate(webSocketFrame) to return a truthy value. Will throw an error if the
WebSocket or Page is closed before the frame is sent.callback - Callback that performs the action triggering the event.Copyright © 2021. All rights reserved.