/// <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); }
/// <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); } }
/// <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; }
/// <summary> /// 异常上下文 /// </summary> /// <param name="context">请求上下文</param> /// <param name="exception">异常</param> public ExceptionContext(RequestContext context, Exception exception) : base(context.Session, context.Packet, context.AllSessions) { this.Exception = exception; }