You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
That code not "Solely" broadcastes the messages, it only grabs "Session"s and "Message"s that came from certain client. For broadcasting them, you have to store them globally by your own, for example, i did it with adding that code on global scope:
let sessions:Arc<Mutex<Vec<Session>>> = Arc::new(Mutex::new(vec![]));
and passed it to the server as web::Data:
.app_data(web::Data::new(sessions.clone()))
then basically grab it on the websocket route, push the session variable in that vector, then iterate that vector in Message::Text and call session.text() on each iteration. If you want, i can add a most basic example on actix/examples. Because it looks hard to understand in first appearance, especially for beginners to the framework.
The text was updated successfully, but these errors were encountered:
In the actix-ws crate, only that example given in documentations and any other guidance exist:
That code not "Solely" broadcastes the messages, it only grabs "Session"s and "Message"s that came from certain client. For broadcasting them, you have to store them globally by your own, for example, i did it with adding that code on global scope:
and passed it to the server as
web::Data
:then basically grab it on the websocket route, push the session variable in that vector, then iterate that vector in
Message::Text
and callsession.text()
on each iteration. If you want, i can add a most basic example on actix/examples. Because it looks hard to understand in first appearance, especially for beginners to the framework.The text was updated successfully, but these errors were encountered: