diff --git a/packages/protocol/hms_protocol/connection.py b/packages/protocol/hms_protocol/connection.py index 0b8f037..96212d2 100644 --- a/packages/protocol/hms_protocol/connection.py +++ b/packages/protocol/hms_protocol/connection.py @@ -65,6 +65,8 @@ class IpcServer: self._heartbeat_task: asyncio.Task | None = None self._last_peer_heartbeat_ns: int = 0 self.capabilities: dict = {} + self.peer_name: str = "" + self.peer_capabilities: dict = {} self.name: str = "hms-renderer" @property @@ -97,10 +99,14 @@ class IpcServer: self._writer = writer # auf hello warten hello_raw = await read_frame_async(reader) - if hello_raw.get("type") != "command" or hello_raw.get("payload", {}).get("action") != "hello": - raise ProtocolError("EXPECTED_HELLO", f"got {hello_raw.get('type')}") + action = hello_raw.get("payload", {}).get("action") + if hello_raw.get("type") != "command" or action != "hello": + got = hello_raw.get("type") + raise ProtocolError("EXPECTED_HELLO", f"got {got}") peer_caps = hello_raw.get("payload", {}).get("capabilities", {}) peer_name = hello_raw.get("payload", {}).get("name", "unknown") + self.peer_name = peer_name + self.peer_capabilities = peer_caps if hello_raw.get("protocol_version") != PROTOCOL_VERSION: err = Envelope( type=MessageType.ERROR, @@ -194,7 +200,8 @@ class IpcClient: if raw.get("type") != "event" or raw.get("payload", {}).get("action") != "welcome": raise ProtocolError("EXPECTED_WELCOME", f"got {raw.get('type')}") if raw.get("protocol_version") != PROTOCOL_VERSION: - raise ProtocolError("VERSION_MISMATCH", f"server sent version {raw.get('protocol_version')}") + sent = raw.get("protocol_version") + raise ProtocolError("VERSION_MISMATCH", f"server sent version {sent}") self._last_peer_heartbeat_ns = time.monotonic_ns() self._heartbeat_task = asyncio.get_running_loop().create_task(self._send_heartbeats()) return HandshakeInfo(