KeyMessage
Overview
KeyMessage is a typed dictionary representing a complete key message received from or sent to the KeySquare platform. It encapsulates both general and key-specific header information for each message.
Definition
from typing import TypedDict
class KeyMessage(TypedDict):
"""
Represents a complete key message.
Attributes:
header: General header information
keyHeader: Key-specific header information
"""
header: Header
keyHeader: KeyHeader
Attributes
At a minimum all KeyMessages will contain the following attributes:
header: General header information for the message. SeeHeaderfor details on the header fields and types.keyHeader: Key-specific header information. SeeKeyHeaderfor details on the key header fields and types.
Usage Example
from keysquarepy import KeyMessage
def handle_message(msg: KeyMessage):
print(f"Header: {msg['header']}")
print(f"KeyHeader: {msg['keyHeader']}")
See Also
KeySession.subscribe()- Subscribing to live data using a KeyMessage callbackHeader- General message header structureKeyHeader- Key-specific header structure