/// <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; taskSetAction.SetAction(SetTypes.SetReturnReult, returnValue); } }
/// <summary> /// 设置Api行为返回的任务异常 /// 设置失败则返远程异常对象 /// </summary> /// <param name="taskSetActionTable">任务行为表</param> /// <param name="requestContext">请求上下文</param> /// <returns></returns> public static RemoteException SetApiActionTaskException(TaskSetActionTable taskSetActionTable, RequestContext requestContext) { var message = JObject.TryCast<string>(requestContext.Packet.body); var taskSetAction = taskSetActionTable.Take(requestContext.Packet.id); if (taskSetAction != null) { taskSetAction.SetAction(SetTypes.SetReturnException, message); return null; } return new RemoteException(message); }
/// <summary> /// Api行为上下文 /// </summary> /// <param name="context">请求上下文</param> /// <param name="action">Api行为</param> public ActionContext(RequestContext context, ApiAction action) : base(context.Session, context.Packet, context.AllSessions) { this.Action = action; }