public Player Join(string playerName, string connectionId)
 {
     if (State.Players.Count(p => p.Name == playerName) != 0)
     {
         return null;
     }
     var player = new Player
     {
         Name = playerName,
         ConnectionId = connectionId,
         PlayerId = _nextId
     };
     State.Players.Add(player);
     GetNextId();
     return player;
 }
 private void HandlePlayerLeft(Player player)
 {
     if (PlayerLeft != null)
         _dispatcher.Dispatch(() => PlayerLeft(this, new PlayerLeftEventArgs(player)));
 }
 public PlayerLeftEventArgs(Player player)
 {
     Player = player;
 }
 public PlayerJoinedEventArgs(Player player)
 {
     Player = player;
 }
 private void ProcessNewPlayerJoined(Player player)
 {
     if(PlayerJoined != null)
         _dispatcher.Dispatch(() => PlayerJoined(this, new PlayerJoinedEventArgs(player)));
 }
 private void HandleNewPlayerJoined(Player player)
 {
     if (PlayerJoined != null)
         _dispatcher.BeginInvoke(() => PlayerJoined(this, new PlayerJoinedEventArgs(player)));
 }