Qucs-S S-parameter Viewer & RF Synthesis Tools
Loading...
Searching...
No Matches
Public Member Functions | List of all members
playwright.async_api._generated.WebSocketRoute Class Reference
Inheritance diagram for playwright.async_api._generated.WebSocketRoute:
Inheritance graph
[legend]
Collaboration diagram for playwright.async_api._generated.WebSocketRoute:
Collaboration graph
[legend]

Public Member Functions

str url (self)
 
None close (self, *typing.Optional[int] code=None, typing.Optional[str] reason=None)
 
"WebSocketRoute" connect_to_server (self)
 
None send (self, typing.Union[str, bytes] message)
 
None on_message (self, typing.Callable[[typing.Union[str, bytes]], typing.Any] handler)
 
None on_close (self, typing.Callable[[typing.Optional[int], typing.Optional[str]], typing.Any] handler)
 
- Public Member Functions inherited from playwright._impl._async_base.AsyncBase
None __init__ (self, Any impl_obj)
 
str __str__ (self)
 
None on (self, Any event, Any f)
 
None once (self, Any event, Any f)
 
None remove_listener (self, Any event, Any f)
 
- Public Member Functions inherited from playwright._impl._impl_to_api_mapping.ImplWrapper
str __repr__ (self)
 

Additional Inherited Members

- Protected Member Functions inherited from playwright._impl._async_base.AsyncBase
Callable[..., None] _wrap_handler (self, Union[Callable[..., Any], Any] handler)
 
- Protected Attributes inherited from playwright._impl._async_base.AsyncBase
 _loop
 
- Protected Attributes inherited from playwright._impl._impl_to_api_mapping.ImplWrapper
 _impl_obj
 

Member Function Documentation

◆ close()

None playwright.async_api._generated.WebSocketRoute.close (   self,
*typing.Optional[int]   code = None,
typing.Optional[str]   reason = None 
)
WebSocketRoute.close

Closes one side of the WebSocket connection.

Parameters
----------
code : Union[int, None]
    Optional [close code](https://developer.mozilla.org/en-US/docs/Web/API/WebSocket/close#code).
reason : Union[str, None]
    Optional [close reason](https://developer.mozilla.org/en-US/docs/Web/API/WebSocket/close#reason).

◆ connect_to_server()

"WebSocketRoute" playwright.async_api._generated.WebSocketRoute.connect_to_server (   self)
WebSocketRoute.connect_to_server

By default, routed WebSocket does not connect to the server, so you can mock entire WebSocket communication. This
method connects to the actual WebSocket server, and returns the server-side `WebSocketRoute` instance, giving the
ability to send and receive messages from the server.

Once connected to the server:
- Messages received from the server will be **automatically forwarded** to the WebSocket in the page, unless
  `web_socket_route.on_message()` is called on the server-side `WebSocketRoute`.
- Messages sent by the [`WebSocket.send()`](https://developer.mozilla.org/en-US/docs/Web/API/WebSocket/send) call
  in the page will be **automatically forwarded** to the server, unless `web_socket_route.on_message()` is
  called on the original `WebSocketRoute`.

See examples at the top for more details.

Returns
-------
WebSocketRoute

◆ on_close()

None playwright.async_api._generated.WebSocketRoute.on_close (   self,
typing.Callable[ [typing.Optional[int], typing.Optional[str]], typing.Any ]  handler 
)
WebSocketRoute.on_close

Allows to handle [`WebSocket.close`](https://developer.mozilla.org/en-US/docs/Web/API/WebSocket/close).

By default, closing one side of the connection, either in the page or on the server, will close the other side.
However, when `web_socket_route.on_close()` handler is set up, the default forwarding of closure is disabled,
and handler should take care of it.

Parameters
----------
handler : Callable[[Union[int, None], Union[str, None]], Any]
    Function that will handle WebSocket closure. Received an optional
    [close code](https://developer.mozilla.org/en-US/docs/Web/API/WebSocket/close#code) and an optional
    [close reason](https://developer.mozilla.org/en-US/docs/Web/API/WebSocket/close#reason).

◆ on_message()

None playwright.async_api._generated.WebSocketRoute.on_message (   self,
typing.Callable[[typing.Union[str, bytes]], typing.Any]   handler 
)
WebSocketRoute.on_message

This method allows to handle messages that are sent by the WebSocket, either from the page or from the server.

When called on the original WebSocket route, this method handles messages sent from the page. You can handle this
messages by responding to them with `web_socket_route.send()`, forwarding them to the server-side connection
returned by `web_socket_route.connect_to_server()` or do something else.

Once this method is called, messages are not automatically forwarded to the server or to the page - you should do
that manually by calling `web_socket_route.send()`. See examples at the top for more details.

Calling this method again will override the handler with a new one.

Parameters
----------
handler : Callable[[Union[bytes, str]], Any]
    Function that will handle messages.

◆ send()

None playwright.async_api._generated.WebSocketRoute.send (   self,
typing.Union[str, bytes]  message 
)
WebSocketRoute.send

Sends a message to the WebSocket. When called on the original WebSocket, sends the message to the page. When called
on the result of `web_socket_route.connect_to_server()`, sends the message to the server. See examples at the
top for more details.

Parameters
----------
message : Union[bytes, str]
    Message to send.

◆ url()

str playwright.async_api._generated.WebSocketRoute.url (   self)
WebSocketRoute.url

URL of the WebSocket created in the page.

Returns
-------
str

The documentation for this class was generated from the following file: