public void LoginPlayerListener(LoginPlayerEvent loginPlayerEvent)
        {
            var connectionPlayer = PlayerManager.Instance.FindPlayerByConnectionId(loginPlayerEvent.ConnectionId);
            var player           = PlayerManager.Instance.FindPlayerById(loginPlayerEvent.PlayerId);

            if (player == null)
            {
                player = CreatePlayer(loginPlayerEvent, connectionPlayer);
            }
            else // Merge to old player
            {
                PlayerManager.Instance.RemovePlayer(connectionPlayer);
                player.PlayerWsService = connectionPlayer.PlayerWsService;
                player.ConnectionId    = connectionPlayer.ConnectionId;
            }

            var yourPlayerEvent = new YourPlayerEvent(player);

            player.PlayerWsService.SendPrivate(yourPlayerEvent);


            var createPlayerEvent = new CreatePlayerEvent(player);

            QueueEvents.Instance.Add(createPlayerEvent);
        }
        public void PlayerLogin(string name, string playerId = "")
        {
            if (_signup)
            {
                throw new NotSupportedException("ReLogin is not supported");
            }
            if (!_connected && !connectWatcher.TryWait(2000) && !_connected)
            {
                throw new NotSupportedException("Client should be connected to server");
            }

            var loginEvent = new LoginPlayerEvent(name, playerId);

            loginEvent.ConnectionId = PlayerInfo.ConnectionId;
            SendMessage(loginEvent);
            // Debug.WriteLine("Czekam na SIGNUP");
            // signupWatcher.Wait();
        }
 private JPlayer CreatePlayer(LoginPlayerEvent loginPlayerEvent, JPlayer connectionPlayer)
 {
     connectionPlayer.Id   = Guid.NewGuid().ToString();
     connectionPlayer.Name = loginPlayerEvent.Name;
     return(connectionPlayer);
 }