Skip to content

Executing send_message from Actix Websocket Chat example #609

Answered by NielDuysters
NielDuysters asked this question in Q&A
Discussion options

You must be logged in to vote

Solution:

async fn send_test(
    srv: web::Data<actix::Addr<websocket_server::ChatServer>>,
) -> Result<HttpResponse> {
    srv.send(websocket_server::ClientMessage {
        id: 0,
        msg: "Test 123".to_string(),
        room: "main".to_string(),
    })
    .await;

    Ok(HttpResponse::Ok().content_type("text/plain").body("OK"))
}

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by robjtede
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant
Converted from issue

This discussion was converted from issue #608 on February 27, 2023 21:06.