0

How do you send a websocket server response (like a json blob) without receiving a message from the client.

For example, how would you make an actix webserver that sends a message to a connected client whenever it receives a message from an mpsc?

Test
  • 962
  • 9
  • 26

1 Answers1

-1

The answer is to use the actix-ws (sub-)library. I found it too hard to do directly using the actix actors. This nice example gives a session object. You can call session.send(...) whenever you want, not just in the incoming message handler.

Test
  • 962
  • 9
  • 26