public Unit ProcessResponse(ActorResponse response) { if (request == null) { ProcessMessage(response); } else { this.response = response; request.Set(); } return(unit); }
internal static RemoteMessageDTO CreateResponse(ActorResponse res, ProcessId to, ProcessId sender) => new RemoteMessageDTO { Type = (int)Message.Type.User, Tag = (int)Message.TagSpec.UserReply, Child = null, Exception = res.IsFaulted ? "RESPERR" : null, To = to.Path, RequestId = res.RequestId, MessageId = Guid.NewGuid(), Sender = res.ReplyFrom.ToString(), ReplyTo = res.ReplyTo.ToString(), ContentType = res.Message.GetType().AssemblyQualifiedName, Content = JsonConvert.SerializeObject(res.Message, ActorSystemConfig.Default.JsonSerializerSettings) };
public R ProcessRequest <R>(ProcessId pid, object message) { try { if (request != null) { throw new Exception("async ask not allowed"); } response = null; request = new AutoResetEvent(false); ActorContext.Ask(pid, new ActorRequest(message, pid, Self, 0), Self); request.WaitOne(ActorConfig.Default.Timeout); if (response == null) { throw new TimeoutException("Request timed out"); } else { if (response.IsFaulted) { var ex = (Exception)response.Message; throw new ProcessException("Process issue: " + ex.Message, pid.Path, Self.Path, ex); } else { return((R)response.Message); } } } finally { if (request != null) { request.Dispose(); request = null; } } }
public Unit ProcessResponse(ActorResponse response) => unit;
internal static RemoteMessageDTO CreateResponse(ActorResponse res, ProcessId to, ProcessId sender, Option<SessionId> sessionId) => new RemoteMessageDTO { Type = (int)Message.Type.User, Tag = (int)Message.TagSpec.UserReply, Child = null, Exception = res.IsFaulted ? "RESPERR" : null, To = to.ToString(), RequestId = res.RequestId, MessageId = Guid.NewGuid(), Sender = res.ReplyFrom.ToString(), ReplyTo = res.ReplyTo.ToString(), ContentType = res.Message.GetType().AssemblyQualifiedName, Content = JsonConvert.SerializeObject(res.Message, ActorSystemConfig.Default.JsonSerializerSettings), SessionId = sessionId.Map(s => s.Value).IfNoneUnsafe(() => null) };
public static void ReplyInbox(ActorResponse res) { }
public static Random Inbox(Random rnd, ActorResponse reply) { var dist = Self.MakeChildId("reply-" + rnd.Next(responseActors)); tell(dist, reply); return rnd; }
internal static RemoteMessageDTO CreateResponse(ActorResponse res, ProcessId to, ProcessId sender) => new RemoteMessageDTO() { Type = (int)Message.Type.User, Tag = (int)Message.TagSpec.UserReply, Child = null, Exception = res.IsFaulted ? "RESPERR" : null, To = to.Path, RequestId = res.RequestId, MessageId = Guid.NewGuid(), Sender = res.ReplyFrom.ToString(), ReplyTo = res.ReplyTo.ToString(), ContentType = res.Message.GetType().AssemblyQualifiedName, Content = JsonConvert.SerializeObject(res.Message, ActorConfig.Default.JsonSerializerSettings) };