示例#1
0
        /// <summary>
        /// 设置Api行为返回的任务结果
        /// </summary>
        /// <param name="requestContext">上下文</param>
        /// <param name="taskSetActionTable">任务行为表</param>
        public static void SetApiActionTaskResult(RequestContext requestContext, TaskSetActionTable taskSetActionTable)
        {
            var taskSetAction = taskSetActionTable.Take(requestContext.Packet.id);

            if (taskSetAction != null)
            {
                var returnValue = requestContext.Packet.body;
                var serializer  = requestContext.Session.Server.JsonSerializer;
                taskSetAction.SetAction(SetTypes.SetReturnReult, returnValue, serializer);
            }
        }
示例#2
0
        /// <summary>
        /// 设置Api行为返回的任务异常
        /// 设置失败则返远程异常对象
        /// </summary>
        /// <param name="taskSetActionTable">任务行为表</param>
        /// <param name="requestContext">请求上下文</param>
        /// <returns></returns>
        public static RemoteException SetApiActionTaskException(TaskSetActionTable taskSetActionTable, RequestContext requestContext)
        {
            var body          = requestContext.Packet.body;
            var message       = body == null ? null : body.ToString();
            var taskSetAction = taskSetActionTable.Take(requestContext.Packet.id);

            if (taskSetAction != null)
            {
                taskSetAction.SetAction(SetTypes.SetReturnException, message, null);
                return(null);
            }
            return(new RemoteException(message));
        }