mxcubecore.ipc.transports.jsonrpc_tcp¶
JSON-RPC 2.0 over a raw, newline-delimited TCP socket, optionally TLS.
Built on gevent.server.StreamServer to match the gevent-based concurrency model as we are using (PyDispatcher/gevent).
Classes
|
Single-client JSON-RPC/TCP transport. |
- class mxcubecore.ipc.transports.jsonrpc_tcp.JSONRPCTCPTransport(host: str, port: int, tls_cert_path: str | None = None, tls_key_path: str | None = None)[source]¶
Bases:
TransportSingle-client JSON-RPC/TCP transport.
- property address¶
The actual bound (host, port).
- 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
- send(session_id: str, raw_json: str) None[source]¶
Send one frame to the given session, if it is still connected.
- start(on_message: Callable[[str, str], None], on_connect: Callable[[str], 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).