-
-
Notifications
You must be signed in to change notification settings - Fork 812
Closed
Description
Hello.
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.
This is my attempt:
async fn send_test(srv: web::Data<actix::Addr<websocket_server::ChatServer>>) {
srv.get_ref().send_message("main", "test message", 1);
}
Error:
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!
Metadata
Metadata
Assignees
Labels
No labels