Browse Source
Merge pull request #26 from fossum/feature/add-enforce-labels-flag
Add source run flag to check response ID
pull/27/head
Richard Neumann
1 year ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with
3 additions and
3 deletions
-
rcon/source/client.py
|
|
@ -64,12 +64,12 @@ class Client(BaseClient, socket_type=SOCK_STREAM): |
|
|
|
|
|
|
|
return True |
|
|
|
|
|
|
|
def run(self, command: str, *args: str, encoding: str = "utf-8") -> str: |
|
|
|
def run(self, command: str, *args: str, encoding: str = "utf-8", enforce_id: bool = True) -> str: |
|
|
|
"""Run a command.""" |
|
|
|
request = Packet.make_command(command, *args, encoding=encoding) |
|
|
|
response = self.communicate(request) |
|
|
|
|
|
|
|
if response.id != request.id: |
|
|
|
raise SessionTimeout() |
|
|
|
if enforce_id and response.id != request.id: |
|
|
|
raise SessionTimeout("packet ID mismatch") |
|
|
|
|
|
|
|
return response.payload.decode(encoding) |
|
|
|