Optimize my Poor Async WebSocket Model

Hi, I write an async WebSocket client myself. But I want to know what's the best practice to implement an async WebSocket client. I'm new to async. :blush:

The main logic is here, https://github.com/l2ust/substrater/blob/main/src/websocket.rs#L58-#L110.

Also, I have this function https://github.com/l2ust/substrater/blob/main/src/websocket.rs#L311 to get the RPC result, but once the connection lost it'll cause a deadlock. How can I check the WebSocket connection state with this crate https://github.com/sdroege/async-tungstenite?

Thanks for taking the time to read my code! :heart:

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.