From 0ae5301585a9c7e658727b62c1f03f25d23a25b2 Mon Sep 17 00:00:00 2001 From: Richard Neumann Date: Sun, 21 Aug 2022 15:23:40 +0200 Subject: [PATCH] Refactor login --- rcon/source/client.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/rcon/source/client.py b/rcon/source/client.py index dc2f14c..110ee64 100644 --- a/rcon/source/client.py +++ b/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: """Perform a login.""" - request = Packet.make_login(passwd, encoding=encoding) - response = self.communicate(request) + self.send(Packet.make_login(passwd, encoding=encoding)) # Wait for SERVERDATA_AUTH_RESPONSE according to: # https://developer.valvesoftware.com/wiki/Source_RCON_Protocol - while response.type != Type.SERVERDATA_AUTH_RESPONSE: - response = self.read() + while (response := self.read()).type != Type.SERVERDATA_AUTH_RESPONSE: + pass if response.id == -1: raise WrongPassword()