p2pfl.communication.protocols.protobuff.client moduleΒΆ

Protocol agnostic client.

class p2pfl.communication.protocols.protobuff.client.ProtobuffClient(self_addr, nei_addr)[source]ΒΆ

Bases: ABC

Client interface.

It is used as a interface to help to decoulple communication protocols based on clien-server architecutes.

abstract connect(handshake_msg=True)[source]ΒΆ

Connect to a neighbor.

Return type:

None

abstract disconnect(disconnect_msg=True)[source]ΒΆ

Disconnect from a neighbor.

Return type:

None

has_temporal_connection()[source]ΒΆ

Check if the client has a temporal connection.

Return type:

bool

Returns:

True if the client has a temporal connection, False otherwise.

abstract is_connected()[source]ΒΆ

Check if a neighbor is connected.

Return type:

bool

Returns:

True if the neighbor is connected, False otherwise.

log_successful_send(msg)[source]ΒΆ

Log a successful message sending.

Parameters:

msg (RootMessage) – The message that was sent.

Return type:

None

abstract send(msg, temporal_connection=False, raise_error=False, disconnect_on_error=True)[source]ΒΆ

Send a message to the neighbor.

Parameters:
  • msg (RootMessage) – Message to send.

  • temporal_connection (bool) – If the connection isn’t stablished and a temporal connection is needed for sending the message.

  • raise_error (bool) – Raise error if an error occurs.

  • disconnect_on_error (bool) – Disconnect if an error occurs.

Return type:

None