public RemoteActor(HeaderChannel output, Uri remoteAddress) { _destinationAddress = ActorUrn.CreateFromRemoteAddress(remoteAddress).ToString(); HeaderChannel headerChannel = new DestinationHeaderChannel(output, _destinationAddress); _output = new MatchHeaderChannel(headerChannel); }
public void Message <TBody>(Message <TBody> message) { if (message.DestinationAddress == null) { Console.WriteLine("No destination"); return; } var urn = new ActorUrn(message.DestinationAddress); Guid key = urn.GetId(); _registry.Get(key, actor => actor.Send(message), () => { Console.WriteLine("Actor not found: " + message.DestinationAddress); }); }
public void Response <TResponse>(Response <TResponse> response) { if (response.DestinationAddress == null) { Console.WriteLine("No destination"); return; } var urn = new ActorUrn(response.DestinationAddress); Guid key = urn.GetId(); _registry.Get(key, actor => actor.Send(response), () => { Console.WriteLine("Actor not found: " + response.DestinationAddress); }); }
public void Run() { Trace.Listeners.Add(new ConsoleTraceListener()); const string remoteAddress = "rm://234.0.0.7:40001/"; Guid id = CombGuid.Generate(); ActorRegistry registry = ActorRegistryFactory.New(x => { x.Remote(r => r.ListenTo(remoteAddress)); }); ActorRef server = AnonymousActor.New(inbox => { inbox.Receive<Response<Hello>>(message => { Console.WriteLine("Hi!"); Console.WriteLine("Request ID: " + message.RequestId); }); }); registry.Register(id, server); var actorAddress = new ActorUrn(remoteAddress, id); registry.Select(actorAddress, actor => { actor.Send<Response<Hello>>(new ResponseImpl<Hello>(new Hello { MyNameIs = "Joe", }, "27")); }, () => {}); ThreadUtil.Sleep(5.Seconds()); registry.Shutdown(); }
public void Run() { Trace.Listeners.Add(new ConsoleTraceListener()); const string remoteAddress = "rm://234.0.0.7:40001/"; Guid id = CombGuid.Generate(); ActorRegistry registry = ActorRegistryFactory.New(x => { x.Remote(r => r.ListenTo(remoteAddress)); }); ActorRef server = AnonymousActor.New(inbox => { inbox.Receive <Response <Hello> >(message => { Console.WriteLine("Hi!"); Console.WriteLine("Request ID: " + message.RequestId); }); }); registry.Register(id, server); var actorAddress = new ActorUrn(remoteAddress, id); registry.Select(actorAddress, actor => { actor.Send <Response <Hello> >(new ResponseImpl <Hello>(new Hello { MyNameIs = "Joe", }, "27")); }, () => {}); ThreadUtil.Sleep(5.Seconds()); registry.Shutdown(); }