berconpy.ArmaDispatcher

class berconpy.ArmaDispatcher

Bases: EventDispatcher

An event dispatcher for ArmaClient.

Methods

add_listener(event, func)

Adds a listener for a given event, e.g. "on_login".

listen([event])

A decorator shorthand to add a listener for a given event, e.g. "on_login".

remove_listener(event, func)

Removes a listener from a given event, e.g. "on_login".

wait_for(event, *[, check, timeout])

Waits for a specific event to occur and returns the result.

Attributes

on_admin_announcement(admin_id, message, /)

Fired when an RCON admin sends a global message.

on_admin_login(admin_id, addr, /)

Fired when a RCON admin logs into the server.

on_admin_message(admin_id, channel, message, /)

Fired when an RCON admin sends a message.

on_admin_whisper(player, admin_id, message, /)

Fired when an RCON admin sends a message to a specific player.

on_command(response, /)

Fired after receiving any command response from the server.

on_login()

Fired after a successful login to the server.

on_message(message, /)

Fired for messages sent by the server, e.g. player connections.

on_player_connect(player, /)

Fired when a player connects to a server.

on_player_disconnect(player, /)

Fired when a player manually disconnects from the server.

on_player_guid(player, /)

Fired when receiving the BattlEye GUID for a connecting player.

on_player_kick(player, reason, /)

Fired when BattlEye kicks a player, either automatically (e.g. "Client not responding") or by an admin (i.e. "Admin Kick").

on_player_message(player, channel, message, /)

Fired when a player sends a message.

on_player_verify_guid(player, /)

Fired when the server has verified the BattlEye GUID for a connecting player.

on_raw_event(packet, /)

Fired for every parsable packet received by the server.

add_listener(event, func)

Adds a listener for a given event, e.g. "on_login".

Parameters:
  • event (str) – The event to listen for.

  • func (Callable[..., Union[Any, Awaitable[Any]]]) – The function to dispatch when the event is received.

listen(event=None)

A decorator shorthand to add a listener for a given event, e.g. "on_login".

Parameters:

event (Optional[str]) – The event to listen for. If None, the function name is used as the event name.

Return type:

Callable[[TypeVar(T)], TypeVar(T)]

remove_listener(event, func)

Removes a listener from a given event, e.g. "on_login".

This method should be a no-op if the given event and function does not match any registered listener.

Parameters:
async wait_for(event, *, check=None, timeout=None)

Waits for a specific event to occur and returns the result.

This allows handling one-shot events in a simpler manner than with persistent listeners.

Parameters:
  • event (str) – The event to wait for, e.g. "login" and "on_login".

  • check (Optional[Callable[..., Union[Any, Awaitable[Any]]]]) – An optional predicate function to use as a filter. This can be either a regular or an asynchronous function. The function should accept the same arguments that the event normally takes.

  • timeout (Union[float, int, None]) – An optional timeout for the function. If this is provided and the function times out, an asyncio.TimeoutError is raised.

Returns:

The same arguments received in the event.

Raises:

asyncio.TimeoutError – The timeout was exceeded while waiting.

on_admin_announcement(admin_id, message, /)

Fired when an RCON admin sends a global message.

Parameters:
  • admin_id (int) – The ID of the admin that sent the message.

  • message (str) – The message that was sent by the admin.

Return type:

Any

on_admin_login(admin_id, addr, /)

Fired when a RCON admin logs into the server.

The first message received will be our client logging in.

Note

This event has no logout equivalent as the server does not send messages for admins logging out.

Parameters:
  • admin_id (int) – The ID of the admin that logged into the server.

  • addr (str) – The admin’s IP and port.

Return type:

Any

on_admin_message(admin_id, channel, message, /)

Fired when an RCON admin sends a message.

If the channel is "Global", the on_admin_announcement() event is dispatched alongside this event.

If the channel starts with "To ", the on_admin_whisper() event is also dispatched.

Parameters:
  • admin_id (int) – The ID of the admin that sent the message.

  • channel (str) – The name of the channel the message was sent to.

  • message (str) – The message that was sent by the admin.

Return type:

Any

on_admin_whisper(player, admin_id, message, /)

Fired when an RCON admin sends a message to a specific player.

Note

This event may potentially not get dispatched if the player’s name could not be found in the client’s cache.

Parameters:
  • player (Player) – The player that the message was directed towards.

  • admin_id (int) – The ID of the admin that sent the message.

  • message (str) – The message that was sent by the admin.

Return type:

Any

on_command(response, /)

Fired after receiving any command response from the server.

This should only be used for debugging purposes as the send_command() method already returns the server’s response.

Parameters:

response (str) – The response received by the server.

Return type:

Any

on_login

Fired after a successful login to the server.

Return type:

Any

on_message(message, /)

Fired for messages sent by the server, e.g. player connections.

More specific events such as on_admin_login() are dispatched from this event.

Parameters:

response – The message that was sent by the server.

Return type:

Any

on_player_connect(player, /)

Fired when a player connects to a server.

Note

The player’s Player.guid will most likely be an empty string since the server sends the GUID in a separate message briefly afterwards. To wait for the GUID to be provided, see the on_player_guid() event.

Parameters:

player (Player) – The player that connected to the server.

Return type:

Any

on_player_disconnect(player, /)

Fired when a player manually disconnects from the server.

The players list will no longer contain the player provided here.

This event does not fire when BattlEye kicks the player; for that, see the following event on_player_kick().

Parameters:

player (Player) – The player that disconnected.

Return type:

Any

on_player_guid(player, /)

Fired when receiving the BattlEye GUID for a connecting player.

The given player object will have the updated GUID.

Parameters:

player (Player) – The player whose GUID was updated.

Return type:

Any

on_player_kick(player, reason, /)

Fired when BattlEye kicks a player, either automatically (e.g. "Client not responding") or by an admin (i.e. "Admin Kick").

The players list will no longer contain the player provided here.

Parameters:
  • player (Player) – The player that was kicked.

  • reason (str) – The reason for the player being kicked.

Return type:

Any

on_player_message(player, channel, message, /)

Fired when a player sends a message.

Parameters:
  • player (Player) – The player that the message was directed towards.

  • channel (str) – The name of the channel the message was sent to.

  • message (str) – The message that was sent by the admin.

Return type:

Any

on_player_verify_guid(player, /)

Fired when the server has verified the BattlEye GUID for a connecting player.

Parameters:

player (Player) – The player whose GUID was verified.

Return type:

Any

on_raw_event(packet, /)

Fired for every parsable packet received by the server.

Parameters:

packet (ServerPacket) – The packet that was received.

Return type:

Any