public void AcceptPlayer(int actorNumber) { if (State == ServerState.Debug) { return; } if (State != ServerState.Started) { throw new InvalidOperationException("Cannot accept player: Server not running"); } for (var i = 0; i < _connections.Length; i++) { NetworkConnection connection = _connections[i]; if (connection.InternalId != actorNumber) { continue; } Debug.Log($"Accepting player of client {actorNumber}"); var connections = new NativeList <NetworkConnection>(1, Allocator.Temp) { connection }; DataStreamWriter writer = _serverDriver.BeginSend(_reliablePipeline, connection); writer.WriteInt(Commands.AcceptPlayer); _serverDriver.EndSend(writer); SendNetAssetUpdate(true, connections); connections.Dispose(); PlayerAccepted?.Invoke(actorNumber); return; } Debug.LogWarning($"Cannot accept player of client {actorNumber}: No connection found"); }
private void SendAccept(ServerPlayer player) { Logger.Log1("Accept Player " + player.PlayerID + ":" + player.Callsign); MsgAccept accept = new MsgAccept(); accept.PlayerID = player.PlayerID; player.SendMessage(accept); PlayerAccepted?.Invoke(this, player); Promote(player); }
private void SecurityArea_PlayerAccepted(object sender, ServerPlayer e) { PlayerAccepted?.Invoke(this, e); }