-
Notifications
You must be signed in to change notification settings - Fork 12
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
Questions about API usage #6
Comments
Hey, sorry I've been behind on issues and PRs, I'm slowly going back through my backlog to catch up.
This is correct, turbulence takes an unreliable stream of packets and turns it into multiplexed streams of optionally reliable messages. How to organize these into different logical connections is out of scope for
My brain is a little fried at the moment so I'm having trouble thinking through the specifics of this sort of use case, but mostly this library is intended for networked realtime games. How I personally use the library is that messages are sent and received inside the main game loop and are ALWAYS sync nonblocking. The reason for this is that if you do something like It's possible that you're adding another layer that handles this nonblocking behavior in a loop that's in front of The async API is mostly intended for startup / shutdown procedures where the client is not yet itself doing a similar 60hz loop. However, in either case, there is a potentially better channels implementation that would allow |
So I've been trying to leverage turbulence for a game I'm writing (a networked fighting game), and I've been trying to make a lobby system to enable a better networked place experience. So far, I've been running into inconveniences while using the API, but I'm not sure if that's me not approaching the problem the correct way or not understanding the API. Here is my actual code that I've been working on for context.
My two main pain points are as follows, hopefully you have ideas on how I can address them:
As you can see, I call the sync nonblocking methods of the messages object to check if theres any data to receiver, and yield_await at the end of the loop. It seems like a better approach would be selecting on the message type OR spawning a new task for each message, but neither of these are viable given that recv/send require an
&mut MessageChannels
. Additionally each recv Future is tied to the lifetime of the borrow, which means I can't return the future to be held around somewhere else. This code forwards each recieved data to a smol::channel, which lets me clone consumers allowing me to engage in behavior like the following:Are there any solutions you would suggest to my issues/should I attempt to PR a design to address them? Thank you for making this really cool library either way!
The text was updated successfully, but these errors were encountered: