Browse Source

added after_connect event triggering

There are cases when you want to accept connection on connect event and then after that do some additional work, for example send the latest updates to user which has just authenticated. This is not possible to do on connect event because in order to send events to the client you need to accept it's connection but for that you need to return from connect event handler and thus you cannot do anything after return.
Without this event you are forced to do this by either accepting all connections and doing authentication on another event or setting up messaging broker and delaying tasks from connect event for example with celery.
pull/167/head
Misha 8 years ago
committed by GitHub
parent
commit
e89171166e
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      socketio/server.py

2
socketio/server.py

@ -428,6 +428,8 @@ class Server(object):
else:
self._send_packet(sid, packet.Packet(packet.CONNECT,
namespace=namespace))
self._trigger_event('after_connect', namespace, sid,
self.environ[sid])
def _handle_disconnect(self, sid, namespace):
"""Handle a client disconnect."""

Loading…
Cancel
Save