Skip to content

Commit

Permalink
fix: improve WebSocket data handling and buffer accumulation
Browse files Browse the repository at this point in the history
  • Loading branch information
revij authored and detiam committed Oct 13, 2024
1 parent 8fef596 commit d34b3a1
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion steam/core/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,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)
Expand Down Expand Up @@ -233,7 +234,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):
Expand Down

0 comments on commit d34b3a1

Please sign in to comment.