Reputation: 374
I have a two namespace I want to trigger event on second namespace once the first namespace event call is completed... (server side)
I tried like this but didnt worked....
class FistNameSpace(socketio.AsyncNamespace):
async def on_connect(self, sid):
pass
#your connection code...
async def on_first_action(self, sid, data):
# your code
result = some_function(data)
SecondNameSpace().trigger_second_action(result)
class SecondNameSpace(socketio.AsyncNamespace):
async def on_connect(self, sid):
pass
#your connection code...
async def trigger_second_action(self, data):
# your code
await self.emit('my_event', data, room=myroom)
How to do it.? Ex: there are two different group of people connected to two different namespace based on their role... if person from first group trigger specific event then I want to broadcast some data to second group....
can someone please advice correct way to achieve it??
Upvotes: 1
Views: 663
Reputation: 67479
The emit()
method supports an optional namespace
argument that you can use to override the namespace on which the event is emitted.
Beyond that, you should move the common behavior that you want to be triggered from two different events to a separate function that you can call from both event handlers.
Upvotes: 1