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
class WebSocketImpl extends ChannelOwner implements WebSocket
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static classWebSocketImpl.EventTypeprivate classWebSocketImpl.WaitableWebSocketClose<T>private classWebSocketImpl.WaitableWebSocketError<T>private static classWebSocketImpl.WebSocketFrameImpl-
Nested classes/interfaces inherited from interface com.microsoft.playwright.WebSocket
WebSocket.WaitForFrameReceivedOptions, WebSocket.WaitForFrameSentOptions
-
-
Field Summary
Fields Modifier and Type Field Description private booleanisClosedprivate ListenerCollection<WebSocketImpl.EventType>listenersprivate PageImplpage-
Fields inherited from class com.microsoft.playwright.impl.ChannelOwner
connection, guid, initializer, type
-
-
Constructor Summary
Constructors Constructor Description WebSocketImpl(ChannelOwner parent, java.lang.String type, java.lang.String guid, com.google.gson.JsonObject initializer)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) voidhandleEvent(java.lang.String event, com.google.gson.JsonObject parameters)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.private WebSocketFramewaitForEventWithTimeout(WebSocketImpl.EventType eventType, java.lang.Runnable code, java.util.function.Predicate<WebSocketFrame> predicate, java.lang.Double timeout)WebSocketFramewaitForFrameReceived(WebSocket.WaitForFrameReceivedOptions options, java.lang.Runnable code)Performs action and waits for a frame to be sent.private WebSocketFramewaitForFrameReceivedImpl(WebSocket.WaitForFrameReceivedOptions options, java.lang.Runnable code)WebSocketFramewaitForFrameSent(WebSocket.WaitForFrameSentOptions options, java.lang.Runnable code)Performs action and waits for a frame to be sent.private WebSocketFramewaitForFrameSentImpl(WebSocket.WaitForFrameSentOptions options, java.lang.Runnable code)-
Methods inherited from class com.microsoft.playwright.impl.ChannelOwner
adopt, disposeChannelOwner, runUntil, sendMessage, sendMessage, sendMessageAsync, toProtocolRef, withLogging, withWaitLogging
-
Methods inherited from class com.microsoft.playwright.impl.LoggingSupport
logApi, logApiIfEnabled, logWithTimestamp, withLogging
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.microsoft.playwright.WebSocket
waitForFrameReceived, waitForFrameSent
-
-
-
-
Field Detail
-
listeners
private final ListenerCollection<WebSocketImpl.EventType> listeners
-
page
private final PageImpl page
-
isClosed
private boolean isClosed
-
-
Constructor Detail
-
WebSocketImpl
WebSocketImpl(ChannelOwner parent, java.lang.String type, java.lang.String guid, com.google.gson.JsonObject initializer)
-
-
Method Detail
-
onClose
public void onClose(java.util.function.Consumer<WebSocket> handler)
Description copied from interface:WebSocketFired when the websocket closes.
-
offClose
public void offClose(java.util.function.Consumer<WebSocket> handler)
Description copied from interface:WebSocketRemoves handler that was previously added withonClose(handler).
-
onFrameReceived
public void onFrameReceived(java.util.function.Consumer<WebSocketFrame> handler)
Description copied from interface:WebSocketFired when the websocket receives a frame.- Specified by:
onFrameReceivedin interfaceWebSocket
-
offFrameReceived
public void offFrameReceived(java.util.function.Consumer<WebSocketFrame> handler)
Description copied from interface:WebSocketRemoves handler that was previously added withonFrameReceived(handler).- Specified by:
offFrameReceivedin interfaceWebSocket
-
onFrameSent
public void onFrameSent(java.util.function.Consumer<WebSocketFrame> handler)
Description copied from interface:WebSocketFired when the websocket sends a frame.- Specified by:
onFrameSentin interfaceWebSocket
-
offFrameSent
public void offFrameSent(java.util.function.Consumer<WebSocketFrame> handler)
Description copied from interface:WebSocketRemoves handler that was previously added withonFrameSent(handler).- Specified by:
offFrameSentin interfaceWebSocket
-
onSocketError
public void onSocketError(java.util.function.Consumer<java.lang.String> handler)
Description copied from interface:WebSocketFired when the websocket has an error.- Specified by:
onSocketErrorin interfaceWebSocket
-
offSocketError
public void offSocketError(java.util.function.Consumer<java.lang.String> handler)
Description copied from interface:WebSocketRemoves handler that was previously added withonSocketError(handler).- Specified by:
offSocketErrorin interfaceWebSocket
-
waitForFrameReceived
public WebSocketFrame waitForFrameReceived(WebSocket.WaitForFrameReceivedOptions options, java.lang.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 interfaceWebSocketcode- Callback that performs the action triggering the event.
-
waitForFrameReceivedImpl
private WebSocketFrame waitForFrameReceivedImpl(WebSocket.WaitForFrameReceivedOptions options, java.lang.Runnable code)
-
waitForFrameSent
public WebSocketFrame waitForFrameSent(WebSocket.WaitForFrameSentOptions options, java.lang.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 sent.- Specified by:
waitForFrameSentin interfaceWebSocketcode- Callback that performs the action triggering the event.
-
waitForFrameSentImpl
private WebSocketFrame waitForFrameSentImpl(WebSocket.WaitForFrameSentOptions options, java.lang.Runnable code)
-
isClosed
public boolean isClosed()
Description copied from interface:WebSocketIndicates that the web socket has been closed.
-
url
public java.lang.String url()
Description copied from interface:WebSocketContains the URL of the WebSocket.
-
waitForEventWithTimeout
private WebSocketFrame waitForEventWithTimeout(WebSocketImpl.EventType eventType, java.lang.Runnable code, java.util.function.Predicate<WebSocketFrame> predicate, java.lang.Double timeout)
-
handleEvent
void handleEvent(java.lang.String event, com.google.gson.JsonObject parameters)- Overrides:
handleEventin classChannelOwner
-
-