Package com.microsoft.playwright.impl
Class WebSocketImpl
java.lang.Object
com.microsoft.playwright.impl.LoggingSupport
com.microsoft.playwright.impl.ChannelOwner
com.microsoft.playwright.impl.WebSocketImpl
- All Implemented Interfaces:
WebSocket
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static enumprivate classprivate classprivate static classNested classes/interfaces inherited from interface com.microsoft.playwright.WebSocket
WebSocket.WaitForFrameReceivedOptions, WebSocket.WaitForFrameSentOptions -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate booleanprivate final ListenerCollection<WebSocketImpl.EventType> private final PageImplFields inherited from class com.microsoft.playwright.impl.ChannelOwner
connection, guid, initializer, type -
Constructor Summary
ConstructorsConstructorDescriptionWebSocketImpl(ChannelOwner parent, String type, String guid, com.google.gson.JsonObject initializer) -
Method Summary
Modifier and TypeMethodDescription(package private) voidhandleEvent(String event, com.google.gson.JsonObject parameters) booleanisClosed()Indicates that the web socket has been closed.voidRemoves handler that was previously added withonClose(handler).voidoffFrameReceived(Consumer<WebSocketFrame> handler) Removes handler that was previously added withonFrameReceived(handler).voidoffFrameSent(Consumer<WebSocketFrame> handler) Removes handler that was previously added withonFrameSent(handler).voidoffSocketError(Consumer<String> handler) Removes handler that was previously added withonSocketError(handler).voidFired when the websocket closes.voidonFrameReceived(Consumer<WebSocketFrame> handler) Fired when the websocket receives a frame.voidonFrameSent(Consumer<WebSocketFrame> handler) Fired when the websocket sends a frame.voidonSocketError(Consumer<String> handler) Fired when the websocket has an error.url()Contains the URL of the WebSocket.private WebSocketFramewaitForEventWithTimeout(WebSocketImpl.EventType eventType, Runnable code, Predicate<WebSocketFrame> predicate, Double timeout) waitForFrameReceived(WebSocket.WaitForFrameReceivedOptions options, Runnable code) Performs action and waits for a frame to be sent.private WebSocketFramewaitForFrameSent(WebSocket.WaitForFrameSentOptions options, Runnable code) Performs action and waits for a frame to be sent.private WebSocketFramewaitForFrameSentImpl(WebSocket.WaitForFrameSentOptions options, Runnable code) Methods inherited from class com.microsoft.playwright.impl.ChannelOwner
adopt, disposeChannelOwner, runUntil, sendMessage, sendMessage, sendMessageAsync, toProtocolRef, withLogging, withWaitLoggingMethods inherited from class com.microsoft.playwright.impl.LoggingSupport
logApi, logApiIfEnabled, logWithTimestamp, withLoggingMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.microsoft.playwright.WebSocket
waitForFrameReceived, waitForFrameSent
-
Field Details
-
listeners
-
page
-
isClosed
private boolean isClosed
-
-
Constructor Details
-
WebSocketImpl
WebSocketImpl(ChannelOwner parent, String type, String guid, com.google.gson.JsonObject initializer)
-
-
Method Details
-
onClose
Description copied from interface:WebSocketFired when the websocket closes. -
offClose
Description copied from interface:WebSocketRemoves handler that was previously added withonClose(handler). -
onFrameReceived
Description copied from interface:WebSocketFired when the websocket receives a frame.- Specified by:
onFrameReceivedin interfaceWebSocket
-
offFrameReceived
Description copied from interface:WebSocketRemoves handler that was previously added withonFrameReceived(handler).- Specified by:
offFrameReceivedin interfaceWebSocket
-
onFrameSent
Description copied from interface:WebSocketFired when the websocket sends a frame.- Specified by:
onFrameSentin interfaceWebSocket
-
offFrameSent
Description copied from interface:WebSocketRemoves handler that was previously added withonFrameSent(handler).- Specified by:
offFrameSentin interfaceWebSocket
-
onSocketError
Description copied from interface:WebSocketFired when the websocket has an error.- Specified by:
onSocketErrorin interfaceWebSocket
-
offSocketError
Description copied from interface:WebSocketRemoves handler that was previously added withonSocketError(handler).- Specified by:
offSocketErrorin interfaceWebSocket
-
waitForFrameReceived
public WebSocketFrame waitForFrameReceived(WebSocket.WaitForFrameReceivedOptions options, Runnable code) Description copied from interface:WebSocketPerforms 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.- Specified by:
waitForFrameReceivedin interfaceWebSocket- Parameters:
code- Callback that performs the action triggering the event.
-
waitForFrameReceivedImpl
private WebSocketFrame waitForFrameReceivedImpl(WebSocket.WaitForFrameReceivedOptions options, Runnable code) -
waitForFrameSent
Description copied from interface:WebSocketPerforms 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.- Specified by:
waitForFrameSentin interfaceWebSocket- Parameters:
code- Callback that performs the action triggering the event.
-
waitForFrameSentImpl
private WebSocketFrame waitForFrameSentImpl(WebSocket.WaitForFrameSentOptions options, Runnable code) -
isClosed
public boolean isClosed()Description copied from interface:WebSocketIndicates that the web socket has been closed. -
url
Description copied from interface:WebSocketContains the URL of the WebSocket. -
waitForEventWithTimeout
private WebSocketFrame waitForEventWithTimeout(WebSocketImpl.EventType eventType, Runnable code, Predicate<WebSocketFrame> predicate, Double timeout) -
handleEvent
- Overrides:
handleEventin classChannelOwner
-