Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to set header,thanks #333

Open
bhltyou opened this issue Jun 16, 2021 · 0 comments
Open

how to set header,thanks #333

bhltyou opened this issue Jun 16, 2021 · 0 comments

Comments

@bhltyou
Copy link

bhltyou commented Jun 16, 2021

if let Err(error) = connect("ws://echo.websocket.org", |out| {
    // Queue a message to be sent when the WebSocket is open
    if out.send("Hello WebSocket").is_err() {
        println!("Websocket couldn't queue an initial message.")
    } else {
        println!("Client sent message 'Hello WebSocket'. ")
    }

    // The handler needs to take ownership of out, so we use move
    move |msg| {
        // Handle messages received on this connection
        println!("Client got message '{}'. ", msg);

        // Close the connection
        out.close(CloseCode::Normal)
    }
}) {
    // Inform the user of failure
    println!("Failed to create WebSocket due to: {:?}", error);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant