示例#1
0
        /// <summary>
        /// 请求脚本处理
        /// </summary>
        /// <param name="userFactory">创建user对象工厂</param>
        public static void RequestScript(Func <int, BaseUser> userFactory = null)
        {
            HttpGet       httpGet  = new HttpGet(HttpContext.Current.Request);
            IGameResponse response = new HttpGameResponse(HttpContext.Current.Response);

            RequestScript(httpGet, response, userFactory);
        }
示例#2
0
        /// <summary>
        /// 请求脚本处理
        /// </summary>
        public static void RequestScript()
        {
            HttpGet          httpGet  = new HttpGet(HttpContext.Current.Request);
            BaseGameResponse response = new HttpGameResponse(HttpContext.Current.Response);

            RequestScript(httpGet, response);
        }
示例#3
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="context"></param>
 public HttpServiceRequest(HttpContext context)
 {
     _buffer     = new MessageStructure();
     httpGet     = new HttpGet(context.Request);
     response    = new HttpGameResponse(context.Response);
     ParamString = httpGet.ParamString;
     SessionId   = httpGet.SessionId;
 }
示例#4
0
        /// <summary>
        /// 请求处理
        /// </summary>
        /// <param name="typeName"></param>
        public static void Request(string typeName)
        {
            if (HttpContext.Current == null)
            {
                throw new Exception("HttpContext is not supported.");
            }
            HttpGet          httpGet  = new HttpGet(HttpContext.Current.Request);
            HttpGameResponse response = new HttpGameResponse(HttpContext.Current.Response);

            Request(typeName, httpGet, response);
        }
示例#5
0
        /// <summary>
        /// 请求处理
        /// </summary>
        /// <param name="typeName"></param>
        /// <param name="userFactory"></param>
        public static void Request(string typeName, Func <int, BaseUser> userFactory)
        {
            if (HttpContext.Current == null)
            {
                throw new Exception("HttpContext is not supported.");
            }
            HttpGet       httpGet  = new HttpGet(HttpContext.Current.Request);
            IGameResponse response = new HttpGameResponse(HttpContext.Current.Response);

            Request(typeName, httpGet, response, userFactory);
        }
示例#6
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="context"></param>
        public void Request(HttpContext context)
        {
            var            actionDispatcher = GameEnvironment.Setting.ActionDispatcher;
            RequestPackage package;

            if (!actionDispatcher.TryDecodePackage(context, out package))
            {
                return;
            }
            var session = GetSession(context, package);

            package.Bind(session);
            ActionGetter     actionGetter = actionDispatcher.GetActionGetter(package);
            BaseGameResponse response     = new HttpGameResponse(context.Response);

            DoAction(actionGetter, response);
        }
        /// <summary>
        /// on web site use
        /// </summary>
        /// <param name="context"></param>
        public void Request(System.Web.HttpContext context)
        {
            string         userHostAddress  = httpListener.HttpCdnAddress.GetUserHostAddress(context.Request.UserHostAddress, key => context.Request.Headers[key]);
            var            actionDispatcher = GameEnvironment.Setting.ActionDispatcher;
            RequestPackage package;

            if (!actionDispatcher.TryDecodePackage(context, out package))
            {
                return;
            }
            var session = GetSession(context, package);

            session.RemoteAddress = userHostAddress;
            package.Bind(session);
            ActionGetter     actionGetter = actionDispatcher.GetActionGetter(package, session);
            BaseGameResponse response     = new HttpGameResponse(context.Response);

            response.WriteErrorCallback += actionDispatcher.ResponseError;
            DoAction(actionGetter, response);
        }
示例#8
0
        protected void Page_Load(object sender, EventArgs e)
        {
            HttpResponse response = HttpContext.Current.Response;

            response.Charset = "unicode";// "unicode";
            HttpGet       httpGet      = new HttpGet(HttpContext.Current.Request);
            IGameResponse gameResponse = new HttpGameResponse(response);
            String        ActionID     = string.Empty;

            if (httpGet.GetString("ActionID", ref ActionID))
            {
                try
                {
                    string   actionName = string.Concat("Action", ActionID);
                    string   sname      = string.Concat("ZyGames.DirCenter.Action." + actionName);
                    object[] args       = new object[1];
                    args[0] = response;

                    BaseStruct obj = (BaseStruct)Activator.CreateInstance(Type.GetType(sname), new object[] { httpGet });
                    obj.DoInit();
                    if (obj.ReadUrlElement() && obj.DoAction() && !obj.GetError())
                    {
                        obj.BuildPacket();
                        obj.WriteAction(gameResponse);
                    }
                    else
                    {
                        obj.WriteErrorAction(gameResponse);
                        return;
                    }
                }
                catch (Exception ex)
                {
                    BaseLog oBaseLog = new BaseLog("DirCenterErrMain");
                    oBaseLog.SaveLog(ex);
                }
            }
        }