1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
//! # 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
//!
//! ```rust,no_run
//! # use ankurah::{Node, PermissiveAgent};
//! # use ankurah_storage_sled::SledStorageEngine;
//! # use ankurah_websocket_client::WebsocketClient;
//! # use ankurah::policy::DEFAULT_CONTEXT as c;
//! # use std::sync::Arc;
//!
//! #[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-export the main types for easy use
pub use ;
pub use WebsocketPeerSender;
// Re-export common types for convenience
pub use WebSocketConfig;
pub use Error as TungsteniteError;