Ejemplo n.º 1
0
 public Unit ProcessResponse(ActorResponse response)
 {
     if (request == null)
     {
         ProcessMessage(response);
     }
     else
     {
         this.response = response;
         request.Set();
     }
     return(unit);
 }
Ejemplo n.º 2
0
 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)
 };
Ejemplo n.º 3
0
        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;
                }
            }
        }
Ejemplo n.º 4
0
 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)
     };
Ejemplo n.º 6
0
 public static void ReplyInbox(ActorResponse res)
 {
 }
Ejemplo n.º 7
0
 public static Random Inbox(Random rnd, ActorResponse reply)
 {
     var dist = Self.MakeChildId("reply-" + rnd.Next(responseActors));
     tell(dist, reply);
     return rnd;
 }
Ejemplo n.º 8
0
 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)
     };
Ejemplo n.º 9
0
 public static void ReplyInbox(ActorResponse res)
 {
 }