wotpy.protocols.ws.messages¶
Classes that represent JSON-RPC messages exchanged over WebSockets.
Functions
parse_ws_message(raw_msg) |
Takes a raw WebSockets message and attempts to parse it to create a message instance. |
Classes
WebsocketMessageEmittedItem(subscription_id, …) |
Represents a Websockets message for an item emitted by an active subscription. |
WebsocketMessageError(message[, code, data, …]) |
Represents a WoT Websockets JSON-RPC error message. |
WebsocketMessageRequest(method, params[, msg_id]) |
Represents a message received on a websocket that contains a JSON-RPC WoT action request. |
WebsocketMessageResponse(result[, msg_id]) |
Represents a WoT Websockets JSON-RPC response message. |
Exceptions
WebsocketMessageException |
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.
-
classmethod
-
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.
-
id¶ ID property.
-
to_dict()¶ Returns this message as a dict.
-
to_json()¶ Returns this message as a JSON string.
-
classmethod
-
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.
-
id¶ ID property.
-
to_dict()¶ Returns this message as a dict.
-
to_json()¶ Returns this message as a JSON string.
-
classmethod
-
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.
-
id¶ ID property.
-
to_dict()¶ Returns this message as a dict.
-
to_json()¶ Returns this message as a JSON string.
-
classmethod
-
wotpy.protocols.ws.messages.parse_ws_message(raw_msg)¶ Takes a raw WebSockets message and attempts to parse it to create a message instance.