Example #1
0
 public override void Execute()
 {
     //#if DEBUG
     //authenticate players from config if needed
     if (config.players.Count > 0)
     {
         foreach (var player in config.players)
         {
             tryLoginSignal.Dispatch(new Credentials() { username = player.username, password = player.password });
         }
         return;
     }
     //#endif
     //determine if we need to authenticate with the server to fetch a token
     var playerToken = PlayerPrefs.GetString(CtacConst.playerToken);
     if (!string.IsNullOrEmpty(playerToken))
     {
         var newPlayer = new PlayerModel()
         {
             clientId = Guid.NewGuid(),
             token = playerToken
         };
         playersModel.players.Add(newPlayer);
         sendAuthToken(newPlayer);
     }
     else
     {
         needLoginSignal.Dispatch();
     }
 }
Example #2
0
 private void onPlayerFetched(PlayerModel p, SocketKey key)
 {
     if (!loginStatuses.ContainsKey(key))
     {
         debug.LogWarning("Key not found in check login statuses");
         return;
     }
     loginStatuses[key].checkSuccess = false;
 }
Example #3
0
 public void AddOrUpdate(PlayerModel player)
 {
     var existing = players.FirstOrDefault(x => x.id == player.id);
     if (existing == null)
     {
         players.Add(player);
     }
     else
     {
         player.CopyProperties(existing);
     }
 }
        private void onFetchComplete(PlayerModel player, SocketKey key)
        {
            if (player == null)
            {
                debug.LogError("Failed Fetching Player", key);
            }
            else
            {
                debug.Log("Player Fetched", key);
                var playerModel = playersModel.GetByClientId(key.clientId);
                //kinda nasty save of the couple properties that need to be saved on the original player model
                //that won't be coming across the wire
                var clientId = playerModel.clientId;
                var token = playerModel.token;
                player.CopyProperties(playerModel);

                playerModel.clientId = clientId;
                playerModel.token = token;
                playerModel.isLocal = true;

                socketService.Disconnect(key.clientId, "auth");
            }
        }
 private void onFetchComplete(PlayerModel player, SocketKey key)
 {
     socketService.Request(key.clientId, "gamelist", "token", player.token);
 }
Example #6
0
 private void sendAuthToken(PlayerModel playerModel)
 {
     socketService.Request(playerModel.clientId, "auth", "token", playerModel.token );
 }