From 376dd565cf3da420b5add46c6c0682eb11c40b33 Mon Sep 17 00:00:00 2001 From: ymgve Date: Sun, 12 Jan 2025 03:19:00 +0100 Subject: [PATCH] Fixed assembly of websocket messages (#7) --- steam/core/connection.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/steam/core/connection.py b/steam/core/connection.py index 277a1dd8..8807f415 100644 --- a/steam/core/connection.py +++ b/steam/core/connection.py @@ -233,9 +233,7 @@ def _reader_loop(self): return logger.debug("Received {} bytes".format(len(data))) - self._readbuf += data - self.ws.receive_data(self._readbuf) - self._readbuf = b'' + self.ws.receive_data(data) self._handle_events() def _handle_events(self): @@ -249,7 +247,11 @@ def _handle_events(self): logger.debug("Received websocket text message of length: {}".format(len(event.data))) elif isinstance(event, wsevents.BytesMessage): logger.debug("Received websocket bytes message of length: {}".format(len(event.data))) - self.recv_queue.put(event.data) + self._readbuf += event.data + if event.message_finished: + self.recv_queue.put(self._readbuf) + self._readbuf = b'' + elif isinstance(event, wsevents.Pong): logger.debug("Received pong: {}".format(repr(event.payload))) elif isinstance(event, wsevents.CloseConnection):