MCPcopy Create free account
hub / github.com/bigdra50/unity-cli / read_frame

Function read_frame

relay/protocol.py:300–311  ·  view source on GitHub ↗

Read a framed message: 4-byte big-endian length + JSON payload

(reader: asyncio.StreamReader)

Source from the content-addressed store, hash-verified

298
299
300async def read_frame(reader: asyncio.StreamReader) -> dict[str, Any]:
301 """Read a framed message: 4-byte big-endian length + JSON payload"""
302 header = await reader.readexactly(HEADER_SIZE)
303 (length,) = struct.unpack(">I", header)
304
305 if length > MAX_PAYLOAD_BYTES:
306 raise ValueError(f"Payload too large: {length} > {MAX_PAYLOAD_BYTES}")
307
308 payload_bytes = await reader.readexactly(length)
309 payload_str = payload_bytes.decode("utf-8")
310
311 return json.loads(payload_str)
312
313
314def write_frame_sync(payload: dict[str, Any]) -> bytes:

Callers 2

_handle_connectionMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected