Пример #1
0
        /// <summary>
        /// 根据指定的账户查找登录信息
        /// </summary>
        /// <param name="account"></param>
        /// <returns></returns>
        public PlayerLoginMessage GetPlayerLoginMessageByAccount(int account)
        {
            PlayerLoginMessage playerLoginMessage = null;
            MySqlCommand       cmd    = new MySqlCommand("select * from tb_playloginmessage where loginaccount=" + account.ToString(), mySqlConnection);
            MySqlDataReader    reader = null;

            try
            {
                mySqlConnection.Open();
                reader = cmd.ExecuteReader();

                while (reader.Read())
                {
                    playerLoginMessage               = new PlayerLoginMessage();
                    playerLoginMessage.LoginId       = int.Parse(reader[0].ToString());
                    playerLoginMessage.LoginAccount  = int.Parse(reader[1].ToString());
                    playerLoginMessage.LoginPassword = reader[2].ToString();
                    playerLoginMessage.LoginPlayer   = int.Parse(reader[3].ToString());
                    break;
                }
            }
            catch (Exception ex) {
                Console.WriteLine(ex.Message);
            }
            finally
            {
                cmd.Dispose();
                reader.Close();
                mySqlConnection.Close();
            }
            return(playerLoginMessage);
        }
Пример #2
0
        private Player Login()
        {
            var message     = new PlayerLoginMessage(PlayerId, _authToken);
            var rawResponse = _messageSender.Send(message);

            using (var stream = new MemoryStream(Encoding.UTF8.GetBytes(rawResponse)))
            {
                var response = (Response <Player>)_loginResponseSerializer.ReadObject(stream);
                var player   = response.Data[0].Result;
                _lastLoginTimeSec = player.Liveness.LastLoginTime;
                return(player);
            }
        }
Пример #3
0
        /// <summary>
        /// 向数据库中插入登录账户信息
        /// </summary>
        /// <param name="playerLoginMessage"></param>
        public void InsertPlayerLoginMessage(PlayerLoginMessage playerLoginMessage)
        {
            string insert_sql = "insert into tb_playloginmessage(loginAccount,loginPassword,playerid) values(" + playerLoginMessage.LoginAccount +
                                ",'" + playerLoginMessage.LoginPassword + "'," + playerLoginMessage.LoginPlayer + ")";
            MySqlCommand cmd = new MySqlCommand(insert_sql, mySqlConnection);

            try
            {
                mySqlConnection.Open();
                cmd.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            finally {
                mySqlConnection.Close();
                cmd.Dispose();
            }
        }
        public void BroadcastPlayerLoginMessage(PlayerLoginMessage message)
        {
            OnRaisePlayerLoginEvent(new ScrimMessageEventArgs <PlayerLoginMessage>(message));

            TrySaveToLogFile(message.Info);
        }