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
(
self, handler: typing.Callable[[typing.Union[str, bytes]], typing.Any]
)
| 1415 | return mapping.from_maybe_impl(self._impl_obj.send(message=message)) |
| 1416 | |
| 1417 | def on_message( |
| 1418 | self, handler: typing.Callable[[typing.Union[str, bytes]], typing.Any] |
| 1419 | ) -> None: |
| 1420 | """WebSocketRoute.on_message |
| 1421 | |
| 1422 | This method allows to handle messages that are sent by the WebSocket, either from the page or from the server. |
| 1423 | |
| 1424 | When called on the original WebSocket route, this method handles messages sent from the page. You can handle this |
| 1425 | messages by responding to them with `web_socket_route.send()`, forwarding them to the server-side connection |
| 1426 | returned by `web_socket_route.connect_to_server()` or do something else. |
| 1427 | |
| 1428 | Once this method is called, messages are not automatically forwarded to the server or to the page - you should do |
| 1429 | that manually by calling `web_socket_route.send()`. See examples at the top for more details. |
| 1430 | |
| 1431 | Calling this method again will override the handler with a new one. |
| 1432 | |
| 1433 | Parameters |
| 1434 | ---------- |
| 1435 | handler : Callable[[Union[bytes, str]], Any] |
| 1436 | Function that will handle messages. |
| 1437 | """ |
| 1438 | |
| 1439 | return mapping.from_maybe_impl( |
| 1440 | self._impl_obj.on_message(handler=self._wrap_handler(handler)) |
| 1441 | ) |
| 1442 | |
| 1443 | def on_close( |
| 1444 | self, |
nothing calls this directly
no test coverage detected