Browse Source

Fix packet reading

pull/14/head 2.2.5
Richard Neumann 3 years ago
parent
commit
ca62d2c349
  1. 7
      rcon/source/client.py

7
rcon/source/client.py

@ -1,6 +1,7 @@
"""Synchronous client."""
from socket import SOCK_STREAM
from typing import IO
from rcon.client import BaseClient
from rcon.exceptions import SessionTimeout, WrongPassword
@ -23,7 +24,11 @@ class Client(BaseClient, socket_type=SOCK_STREAM):
def read(self) -> Packet:
"""Read a packet."""
with self._socket.makefile('rb') as file:
packet = Packet.read(file)
return self._read_from_file(file)
def _read_from_file(self, file: IO) -> Packet:
"""Read a packet from the given file."""
packet = Packet.read(file)
if self._max_packet_size is None:
return packet

Loading…
Cancel
Save