Example #1
0
        public RemoteActor(HeaderChannel output, Uri remoteAddress)
        {
            _destinationAddress = ActorUrn.CreateFromRemoteAddress(remoteAddress).ToString();

            HeaderChannel headerChannel = new DestinationHeaderChannel(output, _destinationAddress);

            _output = new MatchHeaderChannel(headerChannel);
        }
Example #2
0
        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); });
        }
Example #3
0
        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); });
        }
Example #4
0
		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();
		}
Example #5
0
        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();
        }