aea.connections.base
The base connection package.
ConnectionStates Objects
Connection states enum.
Connection Objects
Abstract definition of a connection.
__
init__
| __init__(configuration: ConnectionConfig, data_dir: str, identity: Optional[Identity] = None, crypto_store: Optional[CryptoStore] = None, restricted_to_protocols: Optional[Set[PublicId]] = None, excluded_protocols: Optional[Set[PublicId]] = None, **kwargs: Any, ,) -> None
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.data_dir
: directory where to put local files.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.kwargs
: keyword arguments passed to component base
loop
Get the event loop.
address
Get the address.
crypto_
store
Get the crypto store.
has_
crypto_
store
Check if the connection has the crypto store.
data_
dir
Get the data directory.
component_
type
Get the component type.
configuration
Get the connection configuration.
restricted_
to_
protocols
Get the ids of the protocols this connection is restricted to.
excluded_
protocols
Get the ids of the excluded protocols for this connection.
state
Get the connection status.
state
Set the connection status.
connect
Set up the connection.
disconnect
Tear down the connection.
send
Send an envelope.
Arguments:
envelope
: the envelope to send.
Returns:
None
receive
Receive an envelope.
Arguments:
args
: positional argumentskwargs
: keyword arguments
Returns:
the received envelope, or None if an error occurred.
from_
dir
| @classmethod
| from_dir(cls, directory: str, identity: Identity, crypto_store: CryptoStore, data_dir: str, **kwargs: Any, ,) -> "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.data_dir
: the assets directory.kwargs
: keyword arguments passed to connection base
Returns:
the connection object.
from_
config
| @classmethod
| from_config(cls, configuration: ConnectionConfig, identity: Identity, crypto_store: CryptoStore, data_dir: str, **kwargs: Any, ,) -> "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.data_dir
: the directory of the AEA project data.kwargs
: keyword arguments passed to component base
Returns:
an instance of the concrete connection class.
is_
connected
Return is connected state.
is_
connecting
Return is connecting state.
is_
disconnected
Return is disconnected state.
BaseSyncConnection Objects
Base sync connection class to write connections with sync code.
__
init__
| __init__(configuration: ConnectionConfig, data_dir: str, identity: Optional[Identity] = None, crypto_store: Optional[CryptoStore] = None, restricted_to_protocols: Optional[Set[PublicId]] = None, excluded_protocols: Optional[Set[PublicId]] = None, **kwargs: Any, ,) -> None
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.data_dir
: directory where to put local files.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.kwargs
: keyword arguments passed to connection base
put_
envelope
Put envelope in to the incoming queue.
connect
Connect connection.
disconnect
Disconnect connection.
send
Send envelope to connection.
receive
Get an envelope from the connection.
start_
main
Start main function of the connection.
main
Run main body of the connection in dedicated thread.
on_
connect
Run on connect method called.
on_
disconnect
Run on disconnect method called.
on_
send
Run on send method called.