Ejemplo n.º 1
0
        protected override void OnReceive(object message)
        {
            switch (message)
            {
            case Envelope <Create> c:
            {
                var guid = Guid.NewGuid();

                var cmd  = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Host.exe");
                var args = $"\"{_endpoint}\" {guid} \"{c.Msg.Asm}\" \"{c.Msg.Type}\"";

                Process.Start(cmd, args);
                _senders.Add(guid, Envelope.Create(Sender, c.Sender));
                break;
            }

            case string s when s.StartsWith("register:"):
            {
                var guid     = new Guid(s.Split(':')[1]);
                var returnTo = _senders[guid];
                returnTo.Sender.Tell(new Envelope <IActorRef>(returnTo.Msg, Sender));
                break;
            }

            default:
                Unhandled(message);
                break;
            }
        }
Ejemplo n.º 2
0
        protected override void OnReceive(object message)
        {
            switch (message)
            {
            case Envelope <IActorRef> e:
                e.Sender.Tell(e.Msg);
                break;

            case Create c:
                _registry
                .Ask <Envelope <IActorRef> >(Envelope.Create(Sender, c))
                .PipeTo(Self);
                break;

            default:
                Unhandled(message);
                break;
            }
        }