Browse Source

Refactor login

pull/14/head 2.3.4
Richard Neumann 3 years ago
parent
commit
0ae5301585
  1. 7
      rcon/source/client.py

7
rcon/source/client.py

@ -55,13 +55,12 @@ class Client(BaseClient, socket_type=SOCK_STREAM):
def login(self, passwd: str, *, encoding: str = 'utf-8') -> bool: def login(self, passwd: str, *, encoding: str = 'utf-8') -> bool:
"""Perform a login.""" """Perform a login."""
request = Packet.make_login(passwd, encoding=encoding) self.send(Packet.make_login(passwd, encoding=encoding))
response = self.communicate(request)
# Wait for SERVERDATA_AUTH_RESPONSE according to: # Wait for SERVERDATA_AUTH_RESPONSE according to:
# https://developer.valvesoftware.com/wiki/Source_RCON_Protocol # https://developer.valvesoftware.com/wiki/Source_RCON_Protocol
while response.type != Type.SERVERDATA_AUTH_RESPONSE: while (response := self.read()).type != Type.SERVERDATA_AUTH_RESPONSE:
response = self.read() pass
if response.id == -1: if response.id == -1:
raise WrongPassword() raise WrongPassword()

Loading…
Cancel
Save