Expand description
§Ankurah WebSocket Client
A native (non-browser) WebSocket client for connecting an Ankurah node to another Ankurah node which hosts a WebSocket server
§Automatic reconnection
Reconnects to the server if the connection is lost using exponential backoff
§Graceful shutdown
To shutdown the client, call the shutdown method. This will wait for the connection to be closed and then return.
§Basic Usage
#[tokio::main]
async fn main() -> anyhow::Result<()> {
// Create a client node
let storage = Arc::new(SledStorageEngine::new_test()?);
let my_node = Node::new(storage, PermissiveAgent::new());
// Create WebSocket client to connect to remote server (automatically starts connecting)
let client = WebsocketClient::new(my_node.clone(), "ws://localhost:8080").await?;
println!("State: {}", client.state().value()); // State: Connected
// See [ankurah] for usage details
// When you're done, shutdown the client
client.shutdown().await?;
Ok(())
}// See ankurah for basic details
Re-exports§
pub use client::ConnectionState;pub use client::WebsocketClient;pub use sender::WebsocketPeerSender;
Modules§
Enums§
- Tungstenite
Error - Possible WebSocket errors.