wotpy.protocols.ws.messages
Classes that represent JSON-RPC messages exchanged over WebSockets.
Functions
|
Takes a raw WebSockets message and attempts to parse it to create a message instance. |
Classes
|
Represents a Websockets message for an item emitted by an active subscription. |
|
Represents a WoT Websockets JSON-RPC error message. |
|
Represents a message received on a websocket that contains a JSON-RPC WoT action request. |
|
Represents a WoT Websockets JSON-RPC response message. |
Exceptions
Exception raised when a WS message appears to be invalid. |
- class wotpy.protocols.ws.messages.WebsocketMessageEmittedItem(subscription_id, name, data)
Bases:
objectRepresents a Websockets message for an item emitted by an active subscription.
- classmethod from_raw(raw_msg)
Builds a new WebsocketMessageEmittedItem instance from a raw socket message. Raises WebsocketMessageException if the message is invalid.
- to_dict()
Returns this message as a dict.
- to_json()
Returns this message as a JSON string.
- class wotpy.protocols.ws.messages.WebsocketMessageError(message, code=-32603, data=None, msg_id=None)
Bases:
objectRepresents a WoT Websockets JSON-RPC error message.
- classmethod from_raw(raw_msg)
Builds a new WebsocketMessageError instance from a raw socket message. Raises WebsocketMessageException if the message is invalid.
- property id
ID property.
- to_dict()
Returns this message as a dict.
- to_json()
Returns this message as a JSON string.
- exception wotpy.protocols.ws.messages.WebsocketMessageException
Bases:
ExceptionException raised when a WS message appears to be invalid.
- class wotpy.protocols.ws.messages.WebsocketMessageRequest(method, params, msg_id=None)
Bases:
objectRepresents a message received on a websocket that contains a JSON-RPC WoT action request.
- classmethod from_raw(raw_msg)
Builds a new WebsocketMessageRequest instance from a raw socket message. Raises WebsocketMessageException if the message is invalid.
- property id
ID property.
- to_dict()
Returns this message as a dict.
- to_json()
Returns this message as a JSON string.
- class wotpy.protocols.ws.messages.WebsocketMessageResponse(result, msg_id=None)
Bases:
objectRepresents a WoT Websockets JSON-RPC response message.
- classmethod from_raw(raw_msg)
Builds a new WebsocketMessageResponse instance from a raw socket message. Raises WebsocketMessageException if the message is invalid.
- property id
ID property.
- to_dict()
Returns this message as a dict.
- to_json()
Returns this message as a JSON string.
- wotpy.protocols.ws.messages.parse_ws_message(raw_msg)
Takes a raw WebSockets message and attempts to parse it to create a message instance.