Module awc::ws [−][src]
Expand description
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
Reason for closing the connection
WebSockets protocol codec
WebSocket
connection