コード例 #1
0
ファイル: GetLongBao.cs プロジェクト: zhaoy615/Guizhoule
        public void ExecuteCommand(GameSession session, ProtobufRequestInfo requestInfo)
        {
            var getLongBao = GetLongBaoCount.ParseFrom(requestInfo.Body);

            DAL.DAL.Longbao longbao = new DAL.DAL.Longbao();
            int             count   = longbao.GetLongBaoCount(getLongBao.ID);

            var data = ReturnLongBaoCount.CreateBuilder().SetCount(count).Build().ToByteArray();

            session.Send(new ArraySegment <byte>(CreateHead.CreateMessage(11012, data.Length, requestInfo.MessageNum, data)));
        }
コード例 #2
0
        /// <summary>
        /// 获取龙宝数量
        /// </summary>
        /// <param name="userID"></param>
        /// <returns></returns>
        public static int GetLongBaoNumber(string unionid)
        {
            var data = GetLongBaoCount.CreateBuilder().SetID(unionid).Build().ToByteArray();

            try
            {
                var resData = new MySocket(host, port).SendReceive(CreateHead.CreateMessage(11011, data.Length, 0, data));
                if (resData.FirstOrDefault() != null)
                {
                    return(ReturnLongBaoCount.ParseFrom(resData.FirstOrDefault().Data).Count);
                }
            }
            catch (Exception ex)
            {
                MyLogger.Logger.Info("请求用户登录:" + ex);
            }
            return(0);
        }