-
Notifications
You must be signed in to change notification settings - Fork 41
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
Convenient way to end a session #93
Comments
Thanks for reporting, I'd like a convenient way to do this as well. I think it's best if session starting and closing mirrors each other. So perhaps best to change how we start from inserting a resource to commands as well. Perhaps: let session = session_builder
.start_p2p_session(socket)
.expect("failed to start session, check config");
commands.start_session(session); Or perhaps take a session_builder and socket instead? commands.start_p2p_session(session_builder, socket); |
That would be a nice abstraction. Would it be possible to have the socket returned to us when we end the session? Something like: let socket = commands.end_p2p_session()
.expect("failed to return socket"); |
Not with commands, no. It could perhaps be put into a resource where we could collect it... Not the nicest api, though |
Yeah, that sounds pretty ugly. I like your idea of having the api work entirely thru let socket = session.take_socket();
commands.end_p2p_session(); |
Btw, my workaround for this is to create a newtype around an |
Is your feature request related to a problem? Please describe.
When a player joins or leaves a server, we must remake the P2P session with the appropriate amount of people (gschup/ggrs#23). In bevy_ggrs v0.13, this worked easily by just removing the Session resource before creating a new one:
In v0.14, we must also reset the
GgrsTime
resource. Otherwise the app will panic once synchronization is completed for the 2nd time in an app's lifetime:I also noticed that the new resources
LocalInputs
andPlayerInputs
are not removed or reset, but this doesn't appear to cause any issues for me at the moment.Describe the solution you'd like
A convenient way to end a session. Something like:
Describe alternatives you've considered
It's just a few lines of code for now, so this is only for convenience. Though it certainly caused me a headache to diagnose :)
The text was updated successfully, but these errors were encountered: