0

I have set up a Flask server with JavaScript browser clients connecting to it via websockets.

I am curious for if I can save a certain socket somewhere in python so that I can emit messages to it specifically.

I haven't tried doing anything, but I can't find any info on what I would like to do.

There's no code to provide...

I expected to be able to do something like:

    all_sockets = []

    @socketio.on('connection')
    def on_connect(socket, json, methods=['GET', 'POST']):
        all_sockets.append(socket)

    def whisper(socket, message)
        socket.emit({"data": message})

    whisper(all_sockets[1], "Test")

Much like in node.js's version of websockets it is...

1 Answers1

0

The answer which pretty much solves this I feel is here: flask socketio emit to specific user

I thought I would be able to save the "socket", but that was a somewhat weird line of thought.

I need some more text so I can reply to myself and mark this as a solution to this question so nobody else has to reply to this emberassment.