berconpy.ArmaConnector

class berconpy.ArmaConnector(*, commander=None, config=None, protocol=None)

Bases: AsyncClientConnector

A connector subclass whose keep alive handler has been overridden to periodically refresh the player cache.

Methods

close()

Notifies the protocol that it should begin closing.

connect(password)

Creates a connection to the given address.

connection_lost(exc)

Logs when the protocol has disconnected.

connection_made(transport)

Logs when the protocol has connected.

datagram_received(data, addr)

Handles a datagram from the server.

disconnect()

Disconnects the protocol from the server.

error_received(exc)

Handles an exceptional error from the protocol.

is_connected()

Indicates if the client has a currently active connection with the server.

is_logged_in()

Indicates if the client is currently authenticated with the server.

is_running()

Indicates if the client is running.

run(ip, port, password)

Starts maintaining a connection to the given server.

send(packet)

Sends a packet to the server.

send_command(command)

Attempts to send a command to the server and read the server's response.

wait_for_login()

Waits indefinitely until the client has received a login response or the connection has closed.

Attributes

LAST_RECEIVED_TIMEOUT

client

config

close()

Notifies the protocol that it should begin closing.

Return type:

None

async connect(password)

Creates a connection to the given address.

If necessary, any previous connection will be closed before creating a new connection.

Return type:

bool

Returns:

True if authenticated or False if the connection closed without an error.

Raises:
  • LoginFailure – The client failed to log into the server.

  • OSError – An error occurred while attempting to connect to the server.

connection_lost(exc)

Logs when the protocol has disconnected.

connection_made(transport)

Logs when the protocol has connected.

datagram_received(data, addr)

Handles a datagram from the server.

disconnect()

Disconnects the protocol from the server.

Return type:

None

error_received(exc)

Handles an exceptional error from the protocol.

is_connected()

Indicates if the client has a currently active connection with the server.

Return type:

bool

is_logged_in()

Indicates if the client is currently authenticated with the server.

Return type:

bool

Returns:

True if authenticated or None if no response has been received from the server.

Raises:

LoginFailure – The client failed to log into the server.

is_running()

Indicates if the client is running. This may not necessarily mean that the client is connected.

Return type:

bool

run(ip, port, password)

Starts maintaining a connection to the given server.

Return type:

Task[None]

Returns:

A task that will handle connections to the server.

Raises:

RuntimeError – This method was called while the protocol was already connected.

send(packet)

Sends a packet to the server.

async send_command(command)

Attempts to send a command to the server and read the server’s response.

Parameters:

command (str) – The command string to send.

Return type:

str

Returns:

The server’s response as a string.

Raises:

RCONCommandError – The server failed to respond to all attempts.

async wait_for_login()

Waits indefinitely until the client has received a login response or the connection has closed.

This can also raise any exception when the connection finishes closing.

Return type:

bool

Returns:

True if authenticated, False otherwise.

Raises:

LoginFailure – The client failed to log into the server.