async void HandlePlayerNameMessage(PlayerName message) { if (GetPlayerBySecret(message.Secret) != null) { return; } GameNet.Player netPlayer = BaseServer.GetPlayerBySecret(message.Secret); if (netPlayer == null) { return; } ServerPlayer player = new ServerPlayer(netPlayer, NextPlayerId, message.Name); await BaseServer.SendTo(netPlayer, new PlayerId(player.Id)); await Task.Delay(500); _players[player.Secret] = player; BaseServer.Send(player.ToBasePlayer(), ProtocolType.Udp); EmitPlayerAdded(player); }
void HandleLobbyEnteredMessage(LobbyEntered message) { GameNet.Player player = BaseServer.GetPlayerBySecret(message.Secret); foreach (ServerPlayer p in _players.Values) { BaseServer.SendTo(player, p.ToBasePlayer(), ProtocolType.Udp); } }
public ServerPlayer(GameNet.Player player, int id) : base(id) { GameNetPlayer = player; }