Exemple #1
0
 protected override void DecodePackage(NetReader reader)
 {
     if (reader.StatusCode == 0)
     {
         if (isCustom)
         {
             //自定对象格式解包
             _responseData = ProtoBufUtils.Deserialize<Response1001Pack>(reader.Buffer);
         }
         else
         {
             //默认Scut流格式解包
             _responseData = new Response1001Pack();
             _responseData.PageCount = reader.getInt();
             int nNum = reader.getInt();
             _responseData.Items = new List<RankData>();
             for (int i = 0; i < nNum; i++)
             {
                 reader.recordBegin();
                 RankData item = new RankData();
                 item.UserName = reader.readString();
                 item.Score = reader.getInt();
                 reader.recordEnd();
                 _responseData.Items.Add(item);
             }
         }
     }
 }
Exemple #2
0
 protected override bool DecodePacket(MessageStructure reader, MessageHead head)
 {
     responsePack = ProtoBufUtils.Deserialize<Response1001Pack>(netReader.Buffer);
      string responseDataInfo = "";
      responseDataInfo  = "request :"+Game.Utils.JsonHelper.prettyJson<Request1001Pack>(req) + "\n";
      responseDataInfo += "response:" + Game.Utils.JsonHelper.prettyJson<Response1001Pack>(responsePack) + "\n";
      DecodePacketInfo = responseDataInfo;
     return true;
 }
Exemple #3
0
        public override bool TakeAction()
        {
            int pageCount;
            var cache = new ShareCacheStruct<UserRanking>();
            var rankingList = cache.FindAll(false);
            rankingList = MathUtils.QuickSort<UserRanking>(rankingList, compareTo);
            rankingList = rankingList.GetPaging(requestPack.PageIndex, requestPack.PageSize, out pageCount);

            responsePack = new Response1001Pack();
            responsePack.PageCount = pageCount;
            responsePack.Items = new List<RankData>();
            foreach (var item in rankingList)
            {
                responsePack.Items.Add(new RankData() { UserName = item.UserName, Score = item.Score });
            }
            return true;
        }