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
{{ message }}
Repository navigation
Executing send_message from Actix Websocket Chat example #608
In the Websocket chat example server.rs has this code snippet:
/// Handler for Message message.
impl Handler<ClientMessage> for ChatServer {
type Result = ();
fn handle(&mut self, msg: ClientMessage, _: &mut Context<Self>) {
self.send_message(&msg.room, msg.msg.as_str(), msg.id);
}
}
I want to execute send_message() from any place in my code. For example from a Actix route-function. This way I can make a kind of push-notification system based on this example.
error[E0599]: no method named `send_message` found for reference `&actix::Addr<ChatServer>` in the current scope
--> src/main.rs:1161:19
|
1161 | srv.get_ref().send_message("main", "test message", 1);
| ^^^^^^^^^^^^ method not found in `&actix::Addr<ChatServer>`
For more information about this error, try `rustc --explain E0599`.
So how would I execute send_message() from any place in my code? Thanks!
Activity
NielDuysters commentedon Feb 27, 2023
Solution: