Getting started with Actix-Web Websockets


I have a Actix-Web application where users can place orders. Currently I am making the live order panel where the restaurant owner can view the incoming orders.

This panel needs to be live-updated to display the newly incoming orders. One way to do this is by making a AJAX-request every few minutes to update the order-table.
But I was thinking that there maybe is a better way: Could I use Websockets to get some kind of push-message each time a new order is placed?

Could I use Javascript's Websocket as a client, and in Actix-web send a push message each time an order is placed? How would I start with implementing this?

Axum has an example that implements a simple chat room with WebSockets that would be a good starting point

You could also use server sent events instead of WebSockets, though I'm not sure if there's a significant advantage to doing that anymore?

Edit: oops I misread actix as Axum, my bad! I haven't used Actix, and the repo doesn't have as many examples but the same general principles should apply

1 Like

Thanks. I am getting close. Follow-up question: Executing send_message from Actix Websocket Chat example

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.