WebSocketRoute
Playwright\WebSocket\WebSocketRouteInterface
Methods
close()
voidCloses one side of the WebSocket connection.
function close(array|CloseOptions $options = []): void
connectToServer()
WebSocketRouteInterfaceConnects to the actual WebSocket server. Returns the server-side WebSocketRoute instance.
function connectToServer(): WebSocketRouteInterface
onClose()
voidHandles WebSocket closure. When set, disables default closure forwarding.
function onClose(callable $handler): void
onMessage()
voidHandles messages sent by WebSocket (from page or server). Stops automatic message forwarding.
function onMessage(callable $handler): void
send()
voidSends a message to the WebSocket. Can send to page or server depending on context.
function send(string $message): void
protocols()
arraySubprotocols the page asked for in the WebSocket constructor; empty when it asked for none.
function protocols(): array
url()
stringReturns the URL of the WebSocket created in the page.
function url(): string