Browse Source

Add wildcard event triggered for any event

pull/41/head
Olgierd Grzyb 9 years ago
parent
commit
ae4029b8ba
  1. 1
      socketio/server.py
  2. 7
      tests/test_server.py

1
socketio/server.py

@ -397,6 +397,7 @@ class Server(object):
namespace = namespace or '/'
self.logger.info('received event "%s" from %s [%s]', data[0], sid,
namespace)
self._trigger_event('*', namespace, sid, *data)
r = self._trigger_event(data[0], namespace, sid, *data[1:])
if id is not None:
# send ACK packet with the response returned by the handler

7
tests/test_server.py

@ -269,6 +269,13 @@ class TestServer(unittest.TestCase):
s._handle_eio_message('123', '2["my message","a","b","c"]')
handler.assert_called_once_with('123', 'a', 'b', 'c')
def test_handle_event_wildcard(self, eio):
s = server.Server()
handler = mock.MagicMock()
s.on('*', handler)
s._handle_eio_message('123', '2["my message","a","b","c"]')
handler.assert_called_once_with('123', 'my message', 'a', 'b', 'c')
def test_handle_event_with_namespace(self, eio):
s = server.Server()
handler = mock.MagicMock()

Loading…
Cancel
Save