예제 #1
0
        /// <summary>
        /// 获取Action处理的输出字节流
        /// </summary>
        /// <returns></returns>
        public static byte[] GetActionResponse(int actionId, BaseUser baseUser, string parameters, out HttpGet httpGet)
        {
            string serverHost = string.Format("{0}:{1}", ActionConfig.Current.IpAddress, ActionConfig.Current.Port);
            string param      = string.Format("MsgId={0}&St={1}&Sid={2}&Uid={3}&ActionID={4}{5}",
                                              0,
                                              "st",
                                              baseUser.GetSessionId(),
                                              baseUser.GetUserId(),
                                              actionId,
                                              parameters);

            httpGet = new HttpGet(param, baseUser.SocketSid, baseUser.RemoteAddress);
            BaseStruct         baseStruct = FindRoute(ActionConfig.Current.TypeName, httpGet, actionId);
            SocketGameResponse response   = new SocketGameResponse();

            baseStruct.UserFactory = uid => { return(baseUser); };
            baseStruct.SetPush();
            baseStruct.DoInit();
            using (baseStruct.RequestLock())
            {
                if (!baseStruct.GetError() &&
                    baseStruct.ReadUrlElement() &&
                    baseStruct.DoAction() &&
                    !baseStruct.GetError())
                {
                    baseStruct.BuildPacket();
                    baseStruct.WriteAction(response);
                }
                else
                {
                    baseStruct.WriteErrorAction(response);
                }
            }
            return(response.ReadByte());
        }
예제 #2
0
        /// <summary>
        /// 获取Action处理的输出字节流
        /// </summary>
        /// <returns></returns>
        public static byte[] GetActionResponse(IActionDispatcher actionDispatcher, int actionId, BaseUser baseUser, string urlParam, out ActionGetter actionGetter)
        {
            int userId = baseUser != null?baseUser.GetUserId() : 0;

            GameSession session   = GameSession.Get(userId);
            string      sessionId = session != null ? session.SessionId : "";
            string      param     = string.Format("MsgId={0}&St={1}&Sid={2}&Uid={3}&ActionID={4}{5}",
                                                  0,
                                                  "st",
                                                  sessionId,
                                                  userId,
                                                  actionId,
                                                  urlParam);

            RequestPackage requestPackage = new RequestPackage(0, sessionId, actionId, userId);

            requestPackage.UrlParam    = param;
            requestPackage.IsUrlParam  = true;
            requestPackage.Session     = session;
            requestPackage.ReceiveTime = DateTime.Now;
            actionGetter = new HttpGet(requestPackage);
            BaseStruct         baseStruct = FindRoute(GameEnvironment.Setting.ActionTypeName, actionGetter, actionId);
            SocketGameResponse response   = new SocketGameResponse();

            response.WriteErrorCallback += actionDispatcher.ResponseError;
            baseStruct.UserFactory       = uid => { return(baseUser); };
            baseStruct.SetPush();
            baseStruct.DoInit();
            using (ILocking locking = baseStruct.RequestLock())
            {
                if (locking.IsLocked)
                {
                    if (!baseStruct.GetError() &&
                        baseStruct.ReadUrlElement() &&
                        baseStruct.DoAction() &&
                        !baseStruct.GetError())
                    {
                        baseStruct.WriteResponse(response);
                    }
                    else
                    {
                        baseStruct.WriteErrorAction(response);
                    }
                }
            }
            return(response.ReadByte());
        }
예제 #3
0
        /// <summary>
        /// 获取Action处理的输出字节流
        /// </summary>
        /// <returns></returns>
        public static byte[] GetActionResponse(int actionId, BaseUser baseUser, string parameters, out HttpGet httpGet)
        {
            int userId = baseUser != null?baseUser.GetUserId() : 0;

            GameSession session   = GameSession.Get(userId);
            string      sessionId = session != null ? session.SessionId : "";
            string      param     = string.Format("MsgId={0}&St={1}&Sid={2}&Uid={3}&ActionID={4}{5}",
                                                  0,
                                                  "st",
                                                  sessionId,
                                                  userId,
                                                  actionId,
                                                  parameters);

            httpGet = new HttpGet(param, session);
            BaseStruct         baseStruct = FindRoute(GameEnvironment.Setting.ActionTypeName, httpGet, actionId);
            SocketGameResponse response   = new SocketGameResponse();

            baseStruct.UserFactory = uid => { return(baseUser); };
            baseStruct.SetPush();
            baseStruct.DoInit();
            using (ILocking locking = baseStruct.RequestLock())
            {
                if (locking.IsLocked)
                {
                    if (!baseStruct.GetError() &&
                        baseStruct.ReadUrlElement() &&
                        baseStruct.DoAction() &&
                        !baseStruct.GetError())
                    {
                        baseStruct.BuildPacket();
                        baseStruct.WriteAction(response);
                    }
                    else
                    {
                        baseStruct.WriteErrorAction(response);
                    }
                }
            }
            return(response.ReadByte());
        }
예제 #4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="user"></param>
        public void Notify(BaseUser user)
        {
            int    gameId   = GameEnvironment.ProductCode;
            int    serverId = GameEnvironment.ProductServerId;
            int    userId   = user.GetUserId();
            string pid      = user.GetPassportId();

            OrderInfo[] orderList = PayManager.getPayment(gameId, serverId, pid);
            foreach (var orderInfo in orderList)
            {
                if (DoNotify(userId, orderInfo))
                {
                    PayManager.Abnormal(orderInfo.OrderNO);
                    TraceLog.ReleaseWriteFatal("Payment order:{0},Pid:{1} notify success", orderInfo.OrderNO, pid);
                }
                else
                {
                    TraceLog.ReleaseWriteFatal("Payment order:{0},Pid:{1} notify faild", orderInfo.OrderNO, pid);
                }
            }
        }
예제 #5
0
 public SessionUser(BaseUser user, bool isNew)
 {
     UserId = user.GetUserId();
 }
예제 #6
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="roleUser"></param>
 public SessionUser(BaseUser roleUser)
     : this()
 {
     PassportId = roleUser.GetPassportId();
     UserId     = roleUser.GetUserId();
 }
예제 #7
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="roleUser"></param>
 public SessionUser(BaseUser roleUser)
 {
     OnlineInterval = new TimeSpan(0, 1, 0);
     PassportId     = roleUser.GetPassportId();
     UserId         = roleUser.GetUserId();
 }