Skip to content

Commit

Permalink
prevent binary attachments from getting mixed up
Browse files Browse the repository at this point in the history
Flask-SocketIO issue #385
  • Loading branch information
miguelgrinberg committed Jan 3, 2017
1 parent 652ced7 commit 2c98906
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions socketio/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def __init__(self, client_manager=None, logger=False, binary=False,
self.handlers = {}
self.namespace_handlers = {}

self._binary_packet = []
self._binary_packet = {}

if not isinstance(logger, bool):
self.logger = logger
Expand Down Expand Up @@ -491,10 +491,10 @@ def _handle_eio_connect(self, sid, environ):

def _handle_eio_message(self, sid, data):
"""Dispatch Engine.IO messages."""
if len(self._binary_packet):
pkt = self._binary_packet[0]
if sid in self._binary_packet:
pkt = self._binary_packet[sid]
if pkt.add_attachment(data):
self._binary_packet.pop(0)
del self._binary_packet[sid]
if pkt.packet_type == packet.BINARY_EVENT:
self._handle_event(sid, pkt.namespace, pkt.id, pkt.data)
else:
Expand All @@ -511,7 +511,7 @@ def _handle_eio_message(self, sid, data):
self._handle_ack(sid, pkt.namespace, pkt.id, pkt.data)
elif pkt.packet_type == packet.BINARY_EVENT or \
pkt.packet_type == packet.BINARY_ACK:
self._binary_packet.append(pkt)
self._binary_packet[sid] = pkt
elif pkt.packet_type == packet.ERROR:
raise ValueError('Unexpected ERROR packet.')
else:
Expand Down

0 comments on commit 2c98906

Please sign in to comment.