Exemple #1
0
        /// <summary>
        /// 获取Action处理的输出字节流
        /// </summary>
        /// <returns></returns>
        private static byte[] ProcessActionResponse(IActionDispatcher actionDispatcher, int actionId, ActionGetter actionGetter)
        {
            BaseStruct         baseStruct = ActionFactory.FindRoute(GameEnvironment.Setting.ActionTypeName, actionGetter, actionId);
            SocketGameResponse response   = new SocketGameResponse();

            response.WriteErrorCallback += actionDispatcher.ResponseError;
            baseStruct.SetPush();
            baseStruct.DoInit();
            if (actionGetter.Session.EnterLock(actionId))
            {
                try
                {
                    if (!baseStruct.GetError() &&
                        baseStruct.ReadUrlElement() &&
                        baseStruct.DoAction() &&
                        !baseStruct.GetError())
                    {
                        baseStruct.WriteResponse(response);
                    }
                    else
                    {
                        baseStruct.WriteErrorAction(response);
                    }
                }
                finally
                {
                    actionGetter.Session.ExitLock(actionId);
                }
            }
            else
            {
                baseStruct.WriteLockTimeoutAction(response, false);
            }
            return(response.ReadByte());
        }