MCPcopy Index your code
hub / github.com/microsoft/playwright-python / on_close

Method on_close

playwright/async_api/_generated.py:1443–1467  ·  view source on GitHub ↗

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

(
        self,
        handler: typing.Callable[
            [typing.Optional[int], typing.Optional[str]], typing.Any
        ],
    )

Source from the content-addressed store, hash-verified

1441 )
1442
1443 def on_close(
1444 self,
1445 handler: typing.Callable[
1446 [typing.Optional[int], typing.Optional[str]], typing.Any
1447 ],
1448 ) -> None:
1449 """WebSocketRoute.on_close
1450
1451 Allows to handle [`WebSocket.close`](https://developer.mozilla.org/en-US/docs/Web/API/WebSocket/close).
1452
1453 By default, closing one side of the connection, either in the page or on the server, will close the other side.
1454 However, when `web_socket_route.on_close()` handler is set up, the default forwarding of closure is disabled,
1455 and handler should take care of it.
1456
1457 Parameters
1458 ----------
1459 handler : Callable[[Union[int, None], Union[str, None]], Any]
1460 Function that will handle WebSocket closure. Received an optional
1461 [close code](https://developer.mozilla.org/en-US/docs/Web/API/WebSocket/close#code) and an optional
1462 [close reason](https://developer.mozilla.org/en-US/docs/Web/API/WebSocket/close#reason).
1463 """
1464
1465 return mapping.from_maybe_impl(
1466 self._impl_obj.on_close(handler=self._wrap_handler(handler))
1467 )
1468
1469
1470mapping.register(WebSocketRouteImpl, WebSocketRoute)

Callers

nothing calls this directly

Calls 2

from_maybe_implMethod · 0.80
_wrap_handlerMethod · 0.45

Tested by

no test coverage detected