Skip to main content

decode_client_frame

Function
This function is defined in the protocols module.
Validate a raw inbound frame into a typed, discriminated client frame. This is the single source of truth for the gateway wire contract: it decodes every advertised inbound method (hello, message, leave) and the legacy join handshake into a validated dataclass, or raises :class:FrameDecodeError carrying a structured :class:HelloError for the transport to reject with. Field coercion/validation happens once, here, at the WebSocket boundary — handlers receive already-typed objects.

Signature

Parameters

Dict[str, Any]
required
The raw, JSON-decoded inbound frame (discriminated on type).

Returns

ClientFrame
class:HelloParams, :class:MessageParams, :class:LeaveParams, or :class:JoinParams.

Exceptions

When data is not a mapping, carries an unknown /

Uses

  • FrameDecodeError
  • HelloError
  • MessageParams.from_frame
  • LeaveParams.from_frame
  • JoinParams.from_frame

Source

View on GitHub

praisonaiagents/gateway/protocols.py at line 657

Code Agent

Code Feature