Ejemplo n.º 1
0
        public void ExecuteCommand(GameSession session, ProtobufRequestInfo requestInfo)
        {
            var addLongBao = SendAddLongBao.ParseFrom(requestInfo.Body);

            DAL.DAL.Longbao longbao = new DAL.DAL.Longbao();
            int             state   = 0;

            try
            {
                state = longbao.AddLongBao(addLongBao.UserID, addLongBao.Count, addLongBao.Logging);
            }
            catch (Exception ex)
            {
                MyLogger.Logger.Error(ex);
            }
            if (state == 1)
            {
                var data = ReturnMessage.CreateBuilder().SetState(state).SetMessage("返回成功").Build().ToByteArray();
                session.Send(new ArraySegment <byte>(CreateHead.CreateMessage(11010, data.Length, requestInfo.MessageNum, data)));
                //longbao.AddLongBaoLog(addLongBao.UserID, addLongBao.Logging, count);
                //Console.WriteLine(addLongBao.UserID, addLongBao.Logging, count);
            }
            else
            {
                var data = ReturnMessage.CreateBuilder().SetState(state).SetMessage("返回失败").Build().ToByteArray();
                session.Send(new ArraySegment <byte>(CreateHead.CreateMessage(11010, data.Length, requestInfo.MessageNum, data)));
            }
        }