-
Notifications
You must be signed in to change notification settings - Fork 73
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
Don't require &mut self
for WebRtcSocket::id
, players
#140
Conversation
in #111, id and players started taking `&mut self` and returning `Option<PeerId>` instead of &PeerId. This made the socket a bit more awkward to use. This fixes the &mut self part of it, though you'd still have to deal with the case when `socket.id()` returns `None`.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a nice improvement to the ergonomics. Whilst it would be nice to be able to guarantee an Id in the future this seems like a far better interim solution than the one I had
Okay, merging this. I'm not necessarily opposed to #136 , but I'd like some solution that makes it less awkward to use with bevy, but not exactly sure what that would be... |
A few thoughts:
Perhaps the solution is to provide a bevy Plugin that creates the "socket" resource for you allowing us to hide the ugly async bits |
Yes, something like this feels like the right thing to do, but I find it hard to decide until we've actually tried doing it... |
Honestly I have this pretty much written already for my own game client. I could submit a PR with my abstraction layer. I put a snippet in #136 for viewing. Basically all I do is make the socket a resource and then have the plugin listen for Connect/Disconnect events. On connect, it attempts to create the socket, and if successful will start firing all the socket updates as events. That basically means as a user you're responsible for 2 things:
|
Discussion continued in #144 |
in #111, id and players started taking
&mut self
and returningOption<PeerId>
instead of &PeerId.This made the socket a bit more awkward to use. This fixes the
&mut self
part of it, though you'd still have to deal with the case whensocket.id()
returnsNone
.Alternative to #136