Example #1
0
        public ErrorCode OnCs2DbQueryRanking(NetSessionBase session, Google.Protobuf.IMessage message)
        {
            Protos.CS2DB_QueryRanking request = (Protos.CS2DB_QueryRanking)message;
            int @from = request.From;
            int count = request.Count;

            Protos.DB2CS_QueryRankingRet resp = ProtoCreator.R_CS2DB_QueryRanking(request.Opts.Pid);
            string    str       = $"SELECT id,uname,nickname,avatar,gender,last_login_time,ranking,exp FROM account_user ORDER BY ranking DESC LIMIT {@from}, {count}";
            ErrorCode errorCode = DB.instance.accountDB.SqlExecQuery(str, dataReader =>
            {
                while (dataReader.Read())
                {
                    Protos.DB2CS_RankingInfo rankingInfo = new Protos.DB2CS_RankingInfo();
                    rankingInfo.Ukey          = dataReader.GetUInt32("id");
                    rankingInfo.Name          = dataReader.GetString("nickname");
                    rankingInfo.Avatar        = dataReader.GetString("avatar");
                    rankingInfo.Gender        = dataReader.GetByte("gender");
                    rankingInfo.LastLoginTime = dataReader.GetInt64("last_login_time");
                    rankingInfo.Rank          = dataReader.GetInt32("ranking");
                    rankingInfo.Exp           = dataReader.GetInt32("exp");
                    resp.RankingInfos.Add(rankingInfo);
                }
                return(ErrorCode.Success);
            });

            session.Send(resp);
            return(ErrorCode.Success);
        }
Example #2
0
        private static void OnQueryRankingRet(NetSessionBase session, IMessage message, object[] args)
        {
            CSUser user = ( CSUser )args[0];

            Protos.CS2GC_QueryRankingRet resp   = (Protos.CS2GC_QueryRankingRet)args[1];
            Protos.DB2CS_QueryRankingRet result = (Protos.DB2CS_QueryRankingRet)message;
            foreach (Protos.DB2CS_RankingInfo rankingInfoResult in result.RankingInfos)
            {
                Protos.CS2GC_RankingInfo rankingInfo = new Protos.CS2GC_RankingInfo();
                rankingInfo.Ukey          = rankingInfoResult.Ukey;
                rankingInfo.Name          = rankingInfoResult.Name;
                rankingInfo.Avatar        = rankingInfoResult.Avatar;
                rankingInfo.Gender        = rankingInfoResult.Gender;
                rankingInfo.LastLoginTime = rankingInfoResult.LastLoginTime;
                rankingInfo.Rank          = rankingInfoResult.Rank;
                rankingInfo.Exp           = rankingInfoResult.Exp;
                resp.RankingInfos.Add(rankingInfo);
            }
            user.Send(resp);
        }