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?
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?
Copyright © 2021 Jogjafile Inc.
The answer is to use the
actix-ws(sub-)library. I found it too hard to do directly using theactixactors. This nice example gives asessionobject. You can callsession.send(...)whenever you want, not just in the incoming message handler.