socha.api.networking.xml_protocol_interface#
Here are all incoming byte streams and all outgoing protocol objects handheld.
Module Contents#
Classes#
Serialize and deserialize objects to and from XML. |
Functions#
|
Attributes#
- socha.api.networking.xml_protocol_interface.custom_class_factory(clazz, params: dict)#
- socha.api.networking.xml_protocol_interface.PROTOCOL_PREFIX#
- class socha.api.networking.xml_protocol_interface.XMLProtocolInterface(host: str, port: int)#
Serialize and deserialize objects to and from XML.
- connect()#
Creates a TCP connection with the server.
- disconnect()#
Sends a closing xml to the server and closes the connection afterward.
- _receive()#
Gets a receiving byte stream from the server and deserializes it into an object.
- Returns:
The next object in the stream, or None if the server returns an empty response.
- send(obj: socha.api.protocol.protocol.ProtocolPacket) None#
Sends an object to the server.
- Parameters:
obj – The object to send. Must not be None.
- _encode_context() Iterator[Callable[[Any], bytes]]#
A context manager that yields a function for encoding objects as bytes.
- _deserialize_object(byte_stream: bytes) socha.api.protocol.protocol.ProtocolPacket#
Deserialize a xml byte stream to a ProtocolPacket. :param byte_stream: The byte stream to deserialize. :return: The deserialized ProtocolPacket child.
- _serialize_object(object_class: object) bytes#
Serialize a ProtocolPacket child to a xml byte stream. :param object_class: The ProtocolPacket child to serialize. :return: The serialized byte stream.