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
[MP] Add peer authentication support to the default MultiplayerAPI. #67917
Conversation
4c321bf
to
a80f45b
Compare
Made |
This looks awesome! I've started messing around with it, and it would be nice if the |
I agree, and I think there has historically been some more confusion here since I believe we have a chance to improve this by firing In any case, if we fire WDYT? |
That all makes sense to me! |
I've done the changes as a separate commit, and added the "breaks compat" tag since it changes the |
These changes look great to me! I tried it with my test project, and now |
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.
Code looks good, giant YESS!! to the feature, left a few docs thoughts.
Add few methods to allow peers to exchange authentication information. - `set_auth_callback(callback)`: Enable the authentication features. The callback is a `Callable` that accepts an `int` (the peer ID), and a `PackedByteArray` of data. - The `peer_authenticating(id)` signal will be emitted instead of `peer_connected` when a new peer connects. - Use `send_auth(id: int, data: PackedByteArray)` to exchange data. - Call `complete_auth(id: int)` when the authentication process is complete and you expect to start receiving game data. - The `peer_connected` signal will be emitted as soon as both parties complete the authentication. - Use `disconnect_peer(id)` to disconnect a connected peer. - If the `peer_connected` signal didn't fire for that peer (i.e. it was still in the authentication phase), the `peer_auth_failed` signal will be emitted instead of `peer_disconnected`.
Now handled directly by the MultiplayerAPI implementation.
Thanks! |
Is there any working test for this? It doesn't appear to work because Trying to use
|
Call |
This PR adds support for pre-authenticating peers in
SceneMultiplayer
before letting them join the multiplayer session (i.e. before RPCs and replication starts).Workflow explanation:
set_auth_callback(callback)
to enable the authentication features.The callback must be a
Callable
that accepts anint
(the peer ID), and aPackedByteArray
of data which will be called when authentication data is received.peer_authenticating(id)
signal will be emitted instead ofpeer_connected
when a new peer connects.send_auth(id: int, data: PackedByteArray)
to send authentication data.complete_auth(id: int)
when the authentication process is complete and you expect to start receiving game data.peer_connected
signal will be emitted as soon as both parties complete the authentication.disconnect_peer(id)
to disconnect a connected peer.peer_connected
signal didn't fire for that peer (i.e. it was still in the authentication phase), thepeer_auth_failed
signal will be emitted instead ofpeer_disconnected
.Closes godotengine/godot-proposals#548
Here a demo using it to implement
Draft status:
Based on [MP] Move packet relay and peer signaling code to SceneMultiplayer. #67094MaybeDoneget_pending_peers
method, andauthentication_timeout = 3.0
.master
, whichmay behave been splitted into their own PR, along withMultiplayerPeer.disconnect_peer
andMultiplayerPeer.close
. [MP] Add MultiplayerPeer disconnect_peer, close. #67982