From 1ff8c4e606db9536726ba6218af202752511ea41 Mon Sep 17 00:00:00 2001 From: Richard Neumann Date: Mon, 14 Feb 2022 11:10:03 +0100 Subject: [PATCH] Refactor _receive() --- rcon/battleye/client.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/rcon/battleye/client.py b/rcon/battleye/client.py index 6015555..b378fd6 100644 --- a/rcon/battleye/client.py +++ b/rcon/battleye/client.py @@ -42,9 +42,11 @@ class Client(BaseClient, socket_type=SOCK_DGRAM): def _receive(self, max_length: int) -> Response: """Receives a packet.""" - data = self._socket.recv(max_length)[:7] - header = Header.from_bytes(data) - return RESPONSE_TYPES[header.type].from_bytes(header, data[7:]) + return RESPONSE_TYPES[ + (header := Header.from_bytes( + data := self._socket.recv(max_length)[:7] + )).type + ].from_bytes(header, data[7:]) def receive(self, max_length: int = 4096) -> Response: """Receives a message."""