mxcubecore.ipc.transports.base¶
Transport-agnostic interface used by mxcubecore.ipc.server.IPCServer.
A concrete transport is responsible for connection handling, TLS and message framing; it knows nothing about the raw JSONRPC 2.0 protocol or the whitelist. IPCServer owns the session/auth layer and all envelope handling on top of whatever raw JSON frames a transport delivers.
Classes
Common interface for the JSON-RPC/TCP and NanoMQ transports. |
- class mxcubecore.ipc.transports.base.Transport[source]¶
Bases:
ABCCommon interface for the JSON-RPC/TCP and NanoMQ transports.
- abstract bind(session_id: str) None[source]¶
Called by IPCServer once session_id has authenticated.
Transports that can’t tell clients apart by connection (NanoMQ) use this to reserve the single client slot.
- Parameters:
session_id (str)
- Return type:
None
- abstract send(session_id: str, raw_json: str) None[source]¶
Send one frame to the given session, if it is still connected.
- abstract start(on_message: Callable[[str, str], None], on_connect: Callable[[str, str | None], None], on_disconnect: Callable[[str], None]) None[source]¶
Start listening for (or connecting to) clients.
on_message(session_id, raw_json) is called for every inbound frame.
on_disconnect(session_id) when a client’s connection is torn down at the transport level
on_connect(session_id, peer) is called when a connection is established; peer is a human-readable “ip:port (hostname)” string for transports that have one (JSON-RPC/TCP), or None for transports that don’t (NanoMQ has no per-connection socket only a _client_id in each message).