From 371b9c9f9e7c21ccd6bc7ce842788e68feaac299 Mon Sep 17 00:00:00 2001 From: Ioannis Karamperis <40238062+revij@users.noreply.github.com> Date: Sat, 12 Oct 2024 09:07:12 +0000 Subject: [PATCH] fix: improve WebSocket data handling and buffer accumulation --- steam/core/connection.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/steam/core/connection.py b/steam/core/connection.py index ecf75d92..277a1dd8 100644 --- a/steam/core/connection.py +++ b/steam/core/connection.py @@ -176,6 +176,7 @@ def __init__(self): self.ws = WSConnection(ConnectionType.CLIENT) self.ssl_ctx = ssl.create_default_context(cafile=certifi.where()) self.event_wsdisconnected = event.Event() + self._readbuf = b'' def _new_socket(self): self.raw_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) @@ -232,7 +233,9 @@ def _reader_loop(self): return logger.debug("Received {} bytes".format(len(data))) - self.ws.receive_data(data) + self._readbuf += data + self.ws.receive_data(self._readbuf) + self._readbuf = b'' self._handle_events() def _handle_events(self):