mirror of
https://github.com/jcreek/CosmicClash.git
synced 2026-09-15 13:52:02 +00:00
feat: add allocated server readiness control
This commit is contained in:
@@ -54,6 +54,7 @@ var local_player_name := "Player"
|
||||
# signed authorisation in hello rather than putting it in the endpoint URL.
|
||||
var join_authorisation := ""
|
||||
var require_join_authorisation := false
|
||||
var admissions_open := true
|
||||
var _allowed_join_authorisations: Dictionary = {}
|
||||
var _active_join_peers: Dictionary = {} # opaque authorisation -> peer_id
|
||||
var _join_history: Dictionary = {} # token -> {generation, lost_at}
|
||||
@@ -98,6 +99,7 @@ func _on_shutting_down() -> void:
|
||||
_join_authorisation_context.clear()
|
||||
_join_signing_key = PackedByteArray()
|
||||
require_join_authorisation = false
|
||||
admissions_open = true
|
||||
|
||||
|
||||
func configure_join_authorisations(tokens: Array, context: Dictionary, signing_key: PackedByteArray = PackedByteArray()) -> bool:
|
||||
@@ -122,6 +124,9 @@ func configure_join_authorisations(tokens: Array, context: Dictionary, signing_k
|
||||
func _on_peer_disconnected(peer_id: int) -> void:
|
||||
if not multiplayer.is_server():
|
||||
return
|
||||
if not admissions_open:
|
||||
await _reject(multiplayer.get_remote_sender_id(), "server is draining")
|
||||
return
|
||||
NetworkManager.invalidate_peer(peer_id)
|
||||
_remove_player(peer_id)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user