diff --git a/examples/index.html b/examples/index.html index 263feb85dbdd652090f7c7ecadba82c8138a2f0f..b1930e16c7c8e838a6e8ce98bd9494b2d33d1031 100644 --- a/examples/index.html +++ b/examples/index.html @@ -22,7 +22,7 @@ </style> </head> <script type="module"> - import init from '../target/blocking.js'; + import init from '../target/polling.js'; init(); </script> </html> diff --git a/examples/blocking.rs b/examples/polling.rs similarity index 92% rename from examples/blocking.rs rename to examples/polling.rs index 4a5d01a6d9ee8ae5446563752317fca73f475435..1a864c7f7bd708636343cd8809a949e0542242bb 100644 --- a/examples/blocking.rs +++ b/examples/polling.rs @@ -13,7 +13,7 @@ fn main() -> Result<(), JsValue> { info!("Creating connection"); // Client is wrapped in an Rc<RefCell<>> so it can be used within setInterval - let client = Rc::new(RefCell::new(wasm_sockets::BlockingClient::new( + let client = Rc::new(RefCell::new(wasm_sockets::PollingClient::new( "wss://echo.websocket.org", )?)); diff --git a/src/lib.rs b/src/lib.rs index bba0d953580f4f97181903986006bd6e745eb2d5..b3d17b510e8bbd05f776b422bc554bb817b30ee3 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -89,14 +89,14 @@ pub enum Message { Text(String), Binary(Vec<u8>), } -pub struct BlockingClient { +pub struct PollingClient { pub url: String, pub event_client: EventClient, pub status: Rc<RefCell<ConnectionStatus>>, pub data: Rc<RefCell<Vec<Message>>>, } // TODO: Replace unwraps and JsValue with custom error type -impl BlockingClient { +impl PollingClient { pub fn new(url: &str) -> Result<Self, JsValue> { // Create connection let mut client = EventClient::new(url)?;