예제 #1
0
        /// <summary>
        /// Process authorize, check token and configure connection
        /// </summary>
        /// <param name="client"></param>
        /// <param name="token"></param>
        public void AuthProcess(ClientConnection client, string token)
        {
            using (var db = _dbFactory.OpenSession())
            {
                var model = db.QueryOver <AccountData>().Where(p => p.Token == token).Take(1).SingleOrDefault(); //get account data by token
                if (model == null)                                                                               //if data is null, database not contains token
                {
                    Log.Info($"Cannot find account by token: {token}");
                    client.CloseConnection();
                    return;
                }

                if (model.ExpireTime < DateTime.Now) //if token time has expire, close connection
                {
                    Log.Info($"Token time has expired, account id {model.Id}, close connection");
                    client.CloseConnection();
                    return;
                }

                client.AccountInfo = model;

                var gameToken = RndExt.RandomString(7);

                db.CreateSQLQuery($"UPDATE bd_accounts SET a_game_hash=? WHERE a_id={model.Id} ").SetString(0, gameToken).ExecuteUpdate();

                new SMSG_GetCreateUserInformationToAuthenticServer(gameToken).Send(client);
            }
        }
예제 #2
0
 public void CloseClientRequest(ClientConnection connection)
 {
     Core.Act(s =>
     {
         connection.CloseConnection();
     }, 10000, connection.ActivePlayer.CancelTokenSource);
 }
예제 #3
0
 public void CloseConnections()
 {
     if (ClientConnection != null && ClientConnection.IsConnected)
     {
         ClientConnection.CloseConnection();
     }
     if (ServerConnection != null && ServerConnection.IsConnected)
     {
         ServerConnection.CloseConnection();
     }
 }
예제 #4
0
        public void AuthProcess(ClientConnection client, string token)
        {
            using (var db = _lsDbFactory.OpenSession())
            {
                var model = db.QueryOver <AccountData>().Where(p => p.GameHash == token).Take(1).SingleOrDefault(); //get account data by token
                if (model == null)
                {
                    client.CloseConnection();
                    return;
                }
                if (model.ExpireTime < DateTime.Now)
                {
                    client.CloseConnection();
                    return;
                }

                client.Account = model;

                new SMSG_GetContentServiceInfo().Send(client, false);
                new SMSG_ChargeUser().Send(client, false);

                Core.Act(s => s.LobbyProcessor.GetCharacterList(client));
            }
        }