mokr.connection =============== .. py:module:: mokr.connection Submodules ---------- .. toctree:: :maxdepth: 1 /autoapi/mokr/connection/base/index /autoapi/mokr/connection/connection/index /autoapi/mokr/connection/devtools/index Classes ------- .. autoapisummary:: mokr.connection.Connection mokr.connection.DevtoolsConnection Package Contents ---------------- .. py:class:: Connection(url: str, loop: asyncio.AbstractEventLoop, delay: int = 0) Bases: :py:obj:`pyee.EventEmitter`, :py:obj:`mokr.connection.base.RemoteConnection` Create remote connection. :param url: Websocket URL for remote connection. :type url: str :param loop: Running asyncio loop. :type loop: asyncio.AbstractEventLoop :param delay: Time in milliseconds to wait before handling messages. Defaults to 0. :type delay: int, optional .. py:attribute:: connection :type: mokr.connection.devtools.DevtoolsConnection :value: None .. py:property:: url :type: str Get remote websocket URL. .. py:method:: send(method: str, params: dict = None) -> Awaitable[dict] Send message to remote connection via websocket. :param method: Method to run. :type method: str :param params: Arguments for method, if any. Defaults to None. :type params: dict, optional :raises ConnectionError: Raised if the connection is closed. :returns: Remote response as dictionary. :rtype: Awaitable[dict] .. py:method:: dispose() -> None :async: Sever all connections. .. py:method:: create_session(target_info: dict) -> mokr.connection.devtools.DevtoolsConnection :async: Create a new `mokr.connection.DevtoolsConnection`. :param target_info: Target info from triggered event. :type target_info: dict :returns: New `DevtoolsConnection`. :rtype: DevtoolsConnection .. py:class:: DevtoolsConnection(connection: mokr.connection.connection.Connection | DevtoolsConnection, target_type: str, session_id: str, loop: asyncio.AbstractEventLoop) Bases: :py:obj:`pyee.EventEmitter`, :py:obj:`mokr.connection.base.RemoteConnection` Create new CDP (Chrome Devtools Protocol) session. Most functionality is controlled by calling CDP methods or handling CDP events. Read more about these at: https://chromedevtools.github.io/devtools-protocol/ :param connection: Parent remote connection to use. :type connection: Connection | DevtoolsConnection :param target_type: Type of target this connection is for. :type target_type: str :param session_id: Unique session identifier. :type session_id: str :param loop: Running asyncio loop. :type loop: asyncio.AbstractEventLoop .. py:method:: send(method: str, params: dict = None) -> Awaitable[dict] Send a message to the remote connection. :param method: Method to run. :type method: str :param params: Arguments for method, if any. Defaults to None. :type params: dict, optional :raises NetworkError: Raised if connection is closed. :returns: Remote response as dictionary. :rtype: Awaitable[dict] .. py:method:: detach() -> None :async: Detach session from it's target. Once detached, it is invalid and cannot receive or send messages. :raises NetworkError: Raised if remote connection is already closed.