Browse Source

Wait for SERVERDATA_AUTH_RESPONSE in async client

pull/7/head
Richard Neumann 4 years ago
parent
commit
84d70f00f4
  1. 7
      rcon/asyncio.py

7
rcon/asyncio.py

@ -4,7 +4,7 @@ from asyncio import open_connection
from typing import IO from typing import IO
from rcon.exceptions import RequestIdMismatch, WrongPassword from rcon.exceptions import RequestIdMismatch, WrongPassword
from rcon.proto import Packet from rcon.proto import Packet, Type
__all__ = ['rcon'] __all__ = ['rcon']
@ -26,6 +26,11 @@ async def rcon(command: str, *arguments: str, host: str, port: int,
login = Packet.make_login(passwd) login = Packet.make_login(passwd)
response = await communicate(reader, writer, login) response = await communicate(reader, writer, login)
# Wait for SERVERDATA_AUTH_RESPONSE according to:
# https://developer.valvesoftware.com/wiki/Source_RCON_Protocol
while response.type != Type.SERVERDATA_AUTH_RESPONSE:
response = await Packet.aread(reader)
if response.id == -1: if response.id == -1:
raise WrongPassword() raise WrongPassword()

Loading…
Cancel
Save