예제 #1
0
        static void Main(string[] args)
        {
            NLogLogger.Use();

            ILog log = Logger.Get <Program>();

            var actor = new RpcActor();

            var helloClient = new HelloClient(actor);
            var calcClient  = new CalcClient(actor);

            actor.RegisterRpcService(helloClient);
            actor.RegisterRpcService(calcClient);

            actor.Bootup();

            var container = new TestContainer();

            container.AddModule(new TestModule(helloClient, calcClient));

            var bootstrapper = new Bootstrapper();
            var engine       = bootstrapper.BootWith(container);

            string uri  = "http://localhost:3202/";
            var    host = new SelfHost(engine, new Uri(uri));

            host.Start();
            Console.WriteLine("Server is listening on [{0}].", uri);

            Console.WriteLine("Type something to stop ...");
            Console.ReadKey();

            host.Stop();
            Console.WriteLine("Stopped. Goodbye!");
        }
예제 #2
0
        public TestModule(HelloClient helloService, CalcClient calcService)
        {
            _helloService = helloService;
            _calcService  = calcService;

            Get["/empty"] = x =>
            {
                return(string.Empty);
            };
            Get["/time"] = x =>
            {
                return(DateTime.Now.ToString(@"yyyy-MM-dd HH:mm:ss.fffffff"));
            };
            Get["/hello"] = x =>
            {
                var response = _helloService.SayHello();
                return(response == null ? string.Empty : response.Message.Text);
            };
            Get["/hello10000"] = x =>
            {
                var response = _helloService.SayHello10000();
                return(response == null ? string.Empty : response.Message.Text);
            };
            Get["/add"] = x =>
            {
                var result = _calcService.Add(1, 2);
                return(result.ToString());
            };
        }
예제 #3
0
        static void Main(string[] args)
        {
            NLogLogger.Use();

            ILog log = Logger.Get <Program>();

            var localXmlFilePath = Environment.CurrentDirectory + @"\\XmlConfiguration\\ActorConfiguration.xml";
            var localXmlFileActorConfiguration = LocalXmlFileActorConfiguration.Load(localXmlFilePath);
            var localXmlFileActorDirectory     = new LocalXmlFileActorDirectory(localXmlFileActorConfiguration);

            var actor = new RpcActor(localXmlFileActorConfiguration);

            var helloClient = new HelloClient(actor);
            var calcClient  = new CalcClient(actor);

            actor.RegisterRpcService(helloClient);
            actor.RegisterRpcService(calcClient);

            actor.Bootup(localXmlFileActorDirectory);

            var container = new TestContainer();

            container.AddModule(new TestModule(helloClient, calcClient));

            var bootstrapper = new Bootstrapper();
            var engine       = bootstrapper.BootWith(container);

            string uri  = "http://localhost:3202/";
            var    host = new SelfHost(engine, new Uri(uri));

            host.Start();
            Console.WriteLine("Server is listening on [{0}].", uri);

            Console.WriteLine("Type something to stop ...");
            Console.ReadKey();

            host.Stop();
            Console.WriteLine("Stopped. Goodbye!");
        }