aea.connections.base

The base connection package.

ConnectionStates Objects

class ConnectionStates(Enum)

Connection states enum.

Connection Objects

class Connection(Component,  ABC)

Abstract definition of a connection.

__init__

 | __init__(configuration: ConnectionConfig, identity: Optional[Identity] = None, crypto_store: Optional[CryptoStore] = None, restricted_to_protocols: Optional[Set[PublicId]] = None, excluded_protocols: Optional[Set[PublicId]] = None, **kwargs)

Initialize the connection.

The configuration must be specified if and only if the following parameters are None: connection_id, excluded_protocols or restricted_to_protocols.

Arguments:

  • configuration: the connection configuration.
  • identity: the identity object held by the agent.
  • crypto_store: the crypto store for encrypted communication.
  • restricted_to_protocols: the set of protocols ids of the only supported protocols for this connection.
  • excluded_protocols: the set of protocols ids that we want to exclude for this connection.

loop

 | @property
 | loop() -> Optional[AbstractEventLoop]

Get the event loop.

loop

 | @loop.setter
 | loop(loop: AbstractEventLoop) -> None

Set the event loop.

Arguments:

  • loop: the event loop.

Returns:

None

address

 | @property
 | address() -> "Address"

Get the address.

crypto_store

 | @property
 | crypto_store() -> CryptoStore

Get the crypto store.

has_crypto_store

 | @property
 | has_crypto_store() -> bool

Check if the connection has the crypto store.

component_type

 | @property
 | component_type() -> ComponentType

Get the component type.

configuration

 | @property
 | configuration() -> ConnectionConfig

Get the connection configuration.

restricted_to_protocols

 | @property
 | restricted_to_protocols() -> Set[PublicId]

Get the ids of the protocols this connection is restricted to.

excluded_protocols

 | @property
 | excluded_protocols() -> Set[PublicId]

Get the ids of the excluded protocols for this connection.

state

 | @property
 | state() -> ConnectionStates

Get the connection status.

connect

 | @abstractmethod
 | async connect()

Set up the connection.

disconnect

 | @abstractmethod
 | async disconnect()

Tear down the connection.

send

 | @abstractmethod
 | async send(envelope: "Envelope") -> None

Send an envelope.

Arguments:

  • envelope: the envelope to send.

Returns:

None

receive

 | @abstractmethod
 | async receive(*args, **kwargs) -> Optional["Envelope"]

Receive an envelope.

Returns:

the received envelope, or None if an error occurred.

from_dir

 | @classmethod
 | from_dir(cls, directory: str, identity: Identity, crypto_store: CryptoStore, **kwargs) -> "Connection"

Load the connection from a directory.

Arguments:

  • directory: the directory to the connection package.
  • identity: the identity object.
  • crypto_store: object to access the connection crypto objects.

Returns:

the connection object.

from_config

 | @classmethod
 | from_config(cls, configuration: ConnectionConfig, identity: Identity, crypto_store: CryptoStore, **kwargs) -> "Connection"

Load a connection from a configuration.

Arguments:

  • configuration: the connection configuration.
  • identity: the identity object.
  • crypto_store: object to access the connection crypto objects.

Returns:

an instance of the concrete connection class.

is_connected

 | @property
 | is_connected() -> bool

Return is connected state.

is_disconnected

 | @property
 | is_disconnected() -> bool

Return is disconnected state.