Ejemplo n.º 1
0
    // RegisterAccountAccess
    public static Coroutine RegisterAccountAccess(string ip, string accountId)
    {
        return(IPInfoDB.GetAccounts(
                   ip,
                   data => {
            List <string> accounts;

            if (data == null)
            {
                accounts = new List <string>();
            }
            else
            {
                accounts = new List <string>(data);
            }

            // Save new account id
            if (accounts.IndexOf(accountId) == -1)
            {
                accounts.Add(accountId);
            }

            IPInfoDB.SetAccounts(
                ip,
                accounts.ToArray(),
                ignore => {}
                );
        }
                   ));
    }
Ejemplo n.º 2
0
 // UpdateCountry
 public void UpdateCountry()
 {
     if (IPInfoServer.ipToCountry.ContainsKey(ip))
     {
         IPInfoDB.SetCountry(
             accountId,
             IPInfoServer.ipToCountry[ip],
             data => {
             if (data != null)
             {
                 IPInfoServer.accountIdToCountry[accountId] = data;
             }
         }
             );
     }
 }
Ejemplo n.º 3
0
    // Account login
    void OnAccountLoggedIn(Account account)
    {
        // Save the reference in a dictionary
        var player = new LobbyPlayer(account);

        // Disconnected already?
        // This can happen if the database takes too much time to respond.
        if (player.disconnected)
        {
            LogManager.General.LogWarning("Peer disconnected already, interrupting login process for: " + player.peer);
            return;
        }

        LogManager.General.Log("Account '" + account.name + "' logged in.");

        // Set online status
        player.onlineStatus = OnlineStatus.Online;

        // Async: Retrieve the player information
        SendPublicAccountInfo(
            player.accountId,                   // Account ID
            player                              // Receiver
            );

        // Others
        SettingsDB.GetInputSettings(player);
        AccessLevelsDB.GetAccessLevel(player);
        FriendsDB.GetFriends(player);
        FriendsDB.GetFollowers(player);

        // Async: Set last login date
        LobbyGameDB.SetLastLoginDate(player, System.DateTime.UtcNow);

        // Register access to this account by this IP
        IPInfoDB.RegisterAccountAccess(player.ip, player.accountId);

        // Save country
        player.UpdateCountry();
    }