berconpy.RCONClientProtocol¶
- class berconpy.RCONClientProtocol(*, message_check=None)¶
Bases:
RCONGenericProtocolImplements the client-side portion of the protocol.
- Parameters:
message_check (
Optional[Check[ServerMessagePacket]]) – ACheckthat determines if aServerMessageEventshould be dispatched when aServerMessagePacketis received. IfNone, defaults toNonceCheck(5).
Methods
authenticate(password)Returns the payload needed to authenticate with the server.
Retrieves all events that have been parsed since this was last called.
invalidate_command(sequence)Invalidates any messages received for a response to a given command.
Returns a list of payloads that should be sent to the remote computer.
receive_datagram(data)Handles a packet received by the server.
reset()Resets the protocol to the beginning state.
send_command(command)Returns a payload for sending a command.
Attributes
The current state of the protocol.
- authenticate(password)¶
Returns the payload needed to authenticate with the server.
- Raises:
InvalidStateError – This method can only be called during authentication.
- Return type:
- events_received()¶
Retrieves all events that have been parsed since this was last called.
- Return type:
- invalidate_command(sequence)¶
Invalidates any messages received for a response to a given command.
This should be called whenever a command times out.
If the command sequence was not queued before, this is a no-op.
- Raises:
InvalidStateError – This method can only be called after being logged in.
- Return type:
- packets_to_send()¶
Returns a list of payloads that should be sent to the remote computer.
- Return type:
- receive_datagram(data)¶
Handles a packet received by the server.
- Raises:
InvalidStateError – The given packet cannot be handled in the current state.
ValueError – A malformed packet was provided.
- Return type:
- reset()¶
Resets the protocol to the beginning state.
This method should be invoked when the connection has timed out, meaning the client has either not sent a command within the last 45 seconds, or the client has failed to acknowledge 5 repeats of the same message within 10 seconds.
- Return type:
- send_command(command)¶
Returns a payload for sending a command.
Each invocation of this method increments an internal sequence counter. When retrying a command, it is recommended to re-use the same payload to avoid triggering the same command multiple times.
- Raises:
InvalidStateError – This method can only be called after being logged in.
- Return type:
-
state:
ClientState¶ The current state of the protocol.