-
Notifications
You must be signed in to change notification settings - Fork 33
No-blocking operations for web based clients #30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
No-blocking operations for web based clients #30
Conversation
…bSocket communication
dd089ea
to
2d0fbad
Compare
What are you trying to accomplish? The current design of ewebsock is already non-blocking |
Hello @emilk, thanks for your response, we used ewebsokets to implemented this https://github.com/virto-network/virto-sdk/blob/8e5fadbb4e415e9514b5365401f3598d8264668e/sube/src/ws.rs while I saw we can use the wake up function, there are situations where the context that the wake up needs is not longer accesible by it. In our case we need to "wait" until new messages are coming, but as you were using "try_receiv" it requires to have a loop in a new thread that constantly are asking if there are new messages available, thats why I migrated it to use // before
// waits to wake up function to be called
while let Ok(Some(event)) = receiver.try_receive() {
}
// now you can use this without blocking the current thread
while let Some(event) = receiver.next().await { {
// custom logic here
} |
Hey @emilk , did you have the chance to review it? |
@emilk any thoughts on top of this? or do you recommend to fork a new brand library with this specific changes? |
I'm sorry, I don't have a lot of time on my hands. I don't want to add a bunch of If you want to be able to write |
I would be interested in an async API for both web and native. |
I'd actually be interested in more opinions on this. I do currently use a async API on top of ewebsock in my project. I also needed it to support timeouts. I'm curious about what other people would need. To be clear I do want to keep any async we add separate so that users can opt in if the choose. |
@c-git @S0c5 there is another WebSocket library: https://github.com/nash-io/nash-ws. It works with async on both web and native. I'm using it. |
Thank you for the reference but the non-async version of this library is important because I don't always make calls to the functions from an async context and need to not block as I'm using it in an update loop of egui. |
No description provided.