Package com.microsoft.playwright
Interface WebSocket
-
- All Known Implementing Classes:
WebSocketImpl
public interface WebSocketTheWebSocketclass represents websocket connections in the page.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static classWebSocket.WaitForFrameReceivedOptionsstatic classWebSocket.WaitForFrameSentOptions
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description booleanisClosed()Indicates that the web socket has been closed.voidoffClose(java.util.function.Consumer<WebSocket> handler)Removes handler that was previously added withonClose(handler).voidoffFrameReceived(java.util.function.Consumer<WebSocketFrame> handler)Removes handler that was previously added withonFrameReceived(handler).voidoffFrameSent(java.util.function.Consumer<WebSocketFrame> handler)Removes handler that was previously added withonFrameSent(handler).voidoffSocketError(java.util.function.Consumer<java.lang.String> handler)Removes handler that was previously added withonSocketError(handler).voidonClose(java.util.function.Consumer<WebSocket> handler)Fired when the websocket closes.voidonFrameReceived(java.util.function.Consumer<WebSocketFrame> handler)Fired when the websocket receives a frame.voidonFrameSent(java.util.function.Consumer<WebSocketFrame> handler)Fired when the websocket sends a frame.voidonSocketError(java.util.function.Consumer<java.lang.String> handler)Fired when the websocket has an error.java.lang.Stringurl()Contains the URL of the WebSocket.WebSocketFramewaitForFrameReceived(WebSocket.WaitForFrameReceivedOptions options, java.lang.Runnable callback)Performs action and waits for a frame to be sent.default WebSocketFramewaitForFrameReceived(java.lang.Runnable callback)Performs action and waits for a frame to be sent.WebSocketFramewaitForFrameSent(WebSocket.WaitForFrameSentOptions options, java.lang.Runnable callback)Performs action and waits for a frame to be sent.default WebSocketFramewaitForFrameSent(java.lang.Runnable callback)Performs action and waits for a frame to be sent.
-
-
-
Method Detail
-
onClose
void onClose(java.util.function.Consumer<WebSocket> handler)
Fired when the websocket closes.
-
offClose
void offClose(java.util.function.Consumer<WebSocket> handler)
Removes handler that was previously added withonClose(handler).
-
onFrameReceived
void onFrameReceived(java.util.function.Consumer<WebSocketFrame> handler)
Fired when the websocket receives a frame.
-
offFrameReceived
void offFrameReceived(java.util.function.Consumer<WebSocketFrame> handler)
Removes handler that was previously added withonFrameReceived(handler).
-
onFrameSent
void onFrameSent(java.util.function.Consumer<WebSocketFrame> handler)
Fired when the websocket sends a frame.
-
offFrameSent
void offFrameSent(java.util.function.Consumer<WebSocketFrame> handler)
Removes handler that was previously added withonFrameSent(handler).
-
onSocketError
void onSocketError(java.util.function.Consumer<java.lang.String> handler)
Fired when the websocket has an error.
-
offSocketError
void offSocketError(java.util.function.Consumer<java.lang.String> handler)
Removes handler that was previously added withonSocketError(handler).
-
isClosed
boolean isClosed()
Indicates that the web socket has been closed.- Since:
- v1.8
-
url
java.lang.String url()
Contains the URL of the WebSocket.- Since:
- v1.8
-
waitForFrameReceived
default WebSocketFrame waitForFrameReceived(java.lang.Runnable callback)
Performs action and waits for a frame to be sent. If predicate is provided, it passesWebSocketFramevalue into thepredicatefunction and waits forpredicate(webSocketFrame)to return a truthy value. Will throw an error if the WebSocket or Page is closed before the frame is received.- Parameters:
callback- Callback that performs the action triggering the event.- Since:
- v1.10
-
waitForFrameReceived
WebSocketFrame waitForFrameReceived(WebSocket.WaitForFrameReceivedOptions options, java.lang.Runnable callback)
Performs action and waits for a frame to be sent. If predicate is provided, it passesWebSocketFramevalue into thepredicatefunction and waits forpredicate(webSocketFrame)to return a truthy value. Will throw an error if the WebSocket or Page is closed before the frame is received.- Parameters:
callback- Callback that performs the action triggering the event.- Since:
- v1.10
-
waitForFrameSent
default WebSocketFrame waitForFrameSent(java.lang.Runnable callback)
Performs action and waits for a frame to be sent. If predicate is provided, it passesWebSocketFramevalue into thepredicatefunction and waits forpredicate(webSocketFrame)to return a truthy value. Will throw an error if the WebSocket or Page is closed before the frame is sent.- Parameters:
callback- Callback that performs the action triggering the event.- Since:
- v1.10
-
waitForFrameSent
WebSocketFrame waitForFrameSent(WebSocket.WaitForFrameSentOptions options, java.lang.Runnable callback)
Performs action and waits for a frame to be sent. If predicate is provided, it passesWebSocketFramevalue into thepredicatefunction and waits forpredicate(webSocketFrame)to return a truthy value. Will throw an error if the WebSocket or Page is closed before the frame is sent.- Parameters:
callback- Callback that performs the action triggering the event.- Since:
- v1.10
-
-