MCPcopy Create free account
hub / github.com/Redot-Engine/redot-engine / complete_auth

Method complete_auth

modules/multiplayer/scene_multiplayer.cpp:487–507  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

485}
486
487Error SceneMultiplayer::complete_auth(int p_peer) {
488 ERR_FAIL_COND_V(multiplayer_peer.is_null() || multiplayer_peer->get_connection_status() != MultiplayerPeer::CONNECTION_CONNECTED, ERR_UNCONFIGURED);
489 ERR_FAIL_COND_V(!pending_peers.has(p_peer), ERR_INVALID_PARAMETER);
490 ERR_FAIL_COND_V_MSG(pending_peers[p_peer].local, ERR_FILE_CANT_WRITE, "The authentication session was already marked as completed.");
491 pending_peers[p_peer].local = true;
492
493 // Notify the remote peer that the authentication has completed.
494 uint8_t buf[2] = { NETWORK_COMMAND_SYS, SYS_COMMAND_AUTH };
495 multiplayer_peer->set_target_peer(p_peer);
496 multiplayer_peer->set_transfer_channel(0);
497 multiplayer_peer->set_transfer_mode(MultiplayerPeer::TRANSFER_MODE_RELIABLE);
498 Error err = _send(buf, 2);
499
500 // The remote peer already reported the authentication as completed, so admit the peer.
501 // May generate new packets, so it must happen after sending confirmation.
502 if (pending_peers[p_peer].remote) {
503 pending_peers.erase(p_peer);
504 _admit_peer(p_peer);
505 }
506 return err;
507}
508
509void SceneMultiplayer::set_auth_callback(Callable p_callback) {
510 auth_callback = p_callback;

Callers 1

Calls 7

set_transfer_channelMethod · 0.80
set_transfer_modeMethod · 0.80
is_nullMethod · 0.45
get_connection_statusMethod · 0.45
hasMethod · 0.45
set_target_peerMethod · 0.45
eraseMethod · 0.45

Tested by

no test coverage detected