aea.protocols.base
This module contains the base message and serialization definition.
Message Objects
class Message()
This class implements a message.
Performative Objects
class Performative(Enum)
Performatives for the base message.
__
str__
| __str__()
Get the string representation.
__
init__
| __init__(_body: Optional[Dict] = None, **kwargs)
Initialize a Message object.
Arguments:
body
: the dictionary of values to hold.kwargs
: any additional value to add to the body. It will overwrite the body values.
json
| json() -> dict
Get json friendly str representation of the message.
from_
json
| @classmethod
| from_json(cls, data: dict) -> "Message"
Construct message instance from json data.
valid_
performatives
| @property
| valid_performatives() -> Set[str]
Get valid performatives.
has_
sender
| @property
| has_sender() -> bool
Check if it has a sender.
sender
| @property
| sender() -> Address
Get the sender of the message in Address form.
:return the address
sender
| @sender.setter
| sender(sender: Address) -> None
Set the sender of the message.
has_
to
| @property
| has_to() -> bool
Check if it has a sender.
to
| @property
| to() -> Address
Get address of receiver.
to
| @to.setter
| to(to: Address) -> None
Set address of receiver.
dialogue_
reference
| @property
| dialogue_reference() -> Tuple[str, str]
Get the dialogue_reference of the message.
message_
id
| @property
| message_id() -> int
Get the message_id of the message.
performative
| @property
| performative() -> "Performative"
Get the performative of the message.
target
| @property
| target() -> int
Get the target of the message.
set
| set(key: str, value: Any) -> None
Set key and value pair.
Arguments:
key
: the key.value
: the value.
Returns:
None
get
| get(key: str) -> Optional[Any]
Get value for key.
is_
set
| is_set(key: str) -> bool
Check value is set for key.
__
eq__
| __eq__(other)
Compare with another object.
__
repr__
| __repr__()
Get the representation of the message.
__
str__
| __str__()
Get the string representation of the message. Abbreviated to prevent spamming of logs.
encode
| encode() -> bytes
Encode the message.
decode
| @classmethod
| decode(cls, data: bytes) -> "Message"
Decode the message.
has_
dialogue_
info
| @property
| has_dialogue_info() -> bool
Check whether a message has the dialogue fields populated.
More precisely, it checks whether the fields 'message_id', 'target' and 'dialogue_reference' are set.
Returns:
True if the message has the dialogue fields set, False otherwise.
Encoder Objects
class Encoder(ABC)
Encoder interface.
encode
| @staticmethod
| @abstractmethod
| encode(msg: Message) -> bytes
Encode a message.
Arguments:
msg
: the message to be encoded.
Returns:
the encoded message.
Decoder Objects
class Decoder(ABC)
Decoder interface.
decode
| @staticmethod
| @abstractmethod
| decode(obj: bytes) -> Message
Decode a message.
Arguments:
obj
: the sequence of bytes to be decoded.
Returns:
the decoded message.
Serializer Objects
class Serializer(Encoder, Decoder, ABC)
The implementations of this class defines a serialization layer for a protocol.
Protocol Objects
class Protocol(Component)
This class implements a specifications for a protocol.
It includes a serializer to encode/decode a message.
__
init__
| __init__(configuration: ProtocolConfig, message_class: Type[Message], **kwargs)
Initialize the protocol manager.
Arguments:
configuration
: the protocol configurations.message_class
: the message class.
serializer
| @property
| serializer() -> Type[Serializer]
Get the serializer.
from_
dir
| @classmethod
| from_dir(cls, directory: str, **kwargs) -> "Protocol"
Load the protocol from a directory.
Arguments:
directory
: the directory to the skill package.
Returns:
the protocol object.
from_
config
| @classmethod
| from_config(cls, configuration: ProtocolConfig, **kwargs) -> "Protocol"
Load the protocol from configuration.
Arguments:
configuration
: the protocol configuration.
Returns:
the protocol object.