-1

I have a flask server using flask-socketio, and Angular frontend as a dashboard, and few clients. The dashboard (is also a client) is connected on different namespace ("/dashboard"). Similarly, the clients are also connected to a different namespace ("/clients") and also assigned to respective rooms (country wise).

Now I want to emit an event to a specific user (using request.sid) within a room of the client namespace.

P.S: This is my first time asking a question here so excuse the method :D

1 Answers1

3

so the emit() function has a parameter called room, which you can actually pass the request.sid into

emit('some event', some_data, room=request.sid)

It might be ideal to create your own method for mapping what rooms users are in and what sockets belong to what connected user depending on the complexity of your application. In my case where users in rooms would receive different messages, I needed to.

just an example here, to display the concept


rooms = {
    room1: {
           user1 : {
                   username: "rickybobby",
                   sid: 12ed0u9j1d9a08hy409jdsdf
           }
    },
    roomN : {...userN}
}
Bl3nder
  • 82
  • 5