[][src]Module awc::ws

Websockets client

Type definitions required to use awc::Client as a WebSocket client.

Example

use awc::{Client, ws};
use futures_util::{sink::SinkExt, stream::StreamExt};

#[actix_rt::main]
async fn main() {
    let (_resp, mut connection) = Client::new()
        .ws("ws://echo.websocket.org")
        .connect()
        .await
        .unwrap();

    connection
        .send(ws::Message::Text("Echo".to_string()))
        .await
        .unwrap();
    let response = connection.next().await.unwrap().unwrap();

    assert_eq!(response, ws::Frame::Text("Echo".as_bytes().into()));
}

Structs

CloseReason

Reason for closing the connection

Codec

WebSockets protocol codec

WebsocketsRequest

WebSocket connection

Enums

CloseCode

Status code used to indicate why an endpoint is closing the WebSocket connection.

Frame

WebSocket frame

Message

WebSocket Message