Message¶
The class Message is implemented in file message.py and has this methods:
-
class
wrpclient.message.
Message
¶ Structure that implements WRP message and is used for passing all the information at once
-
static
convert_int_to_message_type
(message_type_value)¶ Static method that converts a given integer to the Message.Type enum ValueError exception when a given integer is not associated with any Message.Type.
Params
- message_type_value: int
Return
Message.Type enum
-
static
create_message
(message_type, **kwargs)¶ Static method that creates new message and sets its attributes by given values. Also add this values into bytes[] with correct order. ValueError exception is raised message type and other attributes does not match according to WRP.
Params
- message_type: Message.Type
- kwargs: dict that should contain values depending on the type of the message
Return
instance of
Message
-
static
create_message_from_buffer
(message_type_value, payload=b'', payload_length=0)¶ Static method that checks if the given message type and payload extracted from a socket correct and decompose it to attributes specific for each message type ValueError exception is raised when given payload’s length and payload_length does not match according to WRP.
Params
- message_type_value: int, code of the message type
- payload: bytes, extracted from the socket
- payload_length: int, length of the payload according to received bytes from the socket
Return
instance of
Message
-
encode
()¶ Encode message along its attributes (message type, payload etc.) to bytearray
Params
None
Return
bytearray containing encoded message
-
static
is_int_valid_message_type
(message_type_value)¶ Static method that checks if a given integer represents valid message type
Params
- message_type_value: int
Return
bool
-
static
xml_to_camera_list
(connector, xml)¶ Static method that convert XML received in CAMERA_LIST message to the list of instances of cameras. ValueError exception is raised when XML is not valid according to WRP.
Params
- connector: WRPConnector that will be used by the camera to communicate with the server
- xml: str, received from the socket
Return
list of instances of
Camera
-
static