Skip to content

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__() -> str

Get the string representation.

__init__

 | __init__(_body: Optional[Dict] = None, **kwargs: Any) -> None

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.

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.

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: Any) -> bool

Compare with another object.

__repr__

 | __repr__() -> str

Get the representation of the message.

__str__

 | __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: Any) -> None

Initialize the protocol manager.

Arguments:

  • configuration: the protocol configurations.
  • message_class: the message class.
  • kwargs: the keyword arguments.

serializer

 | @property
 | serializer() -> Type[Serializer]

Get the serializer.

from_dir

 | @classmethod
 | from_dir(cls, directory: str, **kwargs: Any) -> "Protocol"

Load the protocol from a directory.

Arguments:

  • directory: the directory to the skill package.
  • kwargs: the keyword arguments.

Returns:

the protocol object.

from_config

 | @classmethod
 | from_config(cls, configuration: ProtocolConfig, **kwargs: Any) -> "Protocol"

Load the protocol from configuration.

Arguments:

  • configuration: the protocol configuration.
  • kwargs: the keyword arguments.

Returns:

the protocol object.

protocol_id

 | @property
 | protocol_id() -> PublicId

Get protocol id.

protocol_specification_id

 | @property
 | protocol_specification_id() -> PublicId

Get protocol specification id.

__repr__

 | __repr__() -> str

Get str representation of the protocol.

Back to top