Пример #1
0
        static void Main(string[] args)
        {
            var topologyLoader = new TopologyLoader("../Topology/topology.txt", Encoding.UTF8, new TopologyParser());
            var settingsLoader = new SettingsLoader("../Settings/Host.txt", x => string.Format("../Settings/{0}.txt", x),
                Encoding.UTF8, new HostSettingsParser(), new ServiceSettingsParser());
            var kernel = new RpcClientServer(topologyLoader, settingsLoader);

            kernel.StartHost();

            string line = Console.ReadLine();
            while (line != "exit")
            {
                line = Console.ReadLine();
            }

            kernel.StopHost();
        }
Пример #2
0
        static void Main(string[] args)
        {
            var topologyLoader = new TopologyLoader("../Topology/topology.txt", Encoding.UTF8, new TopologyParser());
            var settingsLoader = new SettingsLoader("../Settings/Host.txt",
                Encoding.UTF8, new HostSettingsParser());
            var kernel = new RpcClientServer(topologyLoader, new TimeoutSettings(5000), settingsLoader, new RpcComponentOverrides
            {
                Logger = c => new FileLogger("hostlog.txt")
            });

            kernel.StartHost();

            string line = Console.ReadLine();
            while (line != "exit")
            {
                line = Console.ReadLine();
            }

            kernel.StopHost();
        }
Пример #3
0
        static void Main(string[] args)
        {
            var topologyLoader = new TopologyLoader("../Topology/topology.txt", Encoding.UTF8, new TopologyParser());
            var client = new RpcClient(topologyLoader);

            var myService = client.GetService<IMyService>();

            string line;
            while ((line = Console.ReadLine()) != "exit")
            {
                switch (line)
                {
                    case "greet":
                    {
                        Console.Write("Enter a name: ");
                        var name = Console.ReadLine();
                        var greeting = myService.Greet(name);
                        Console.WriteLine(greeting);
                    }
                    break;
                    case "add":
                    {
                        Console.Write("Enter a: ");
                        var a = int.Parse(Console.ReadLine());
                        Console.Write("Enter b: ");
                        var b = int.Parse(Console.ReadLine());
                        var sum = myService.Add(a, b);
                        Console.WriteLine(sum);
                    }
                    break;
                    default:
                    {
                        Console.WriteLine("Unkown command");
                    }
                    break;
                }
            }
        }
Пример #4
0
        static void Main(string[] args)
        {
            var topologyLoader = new TopologyLoader("../Topology/topology.txt", Encoding.UTF8, new TopologyParser());
            var client = new RpcClient(topologyLoader, new TimeoutSettings(500));

            var myService = client.GetService<IMyService>();

            string line;
            while ((line = Console.ReadLine()) != "exit")
            {
                switch (line)
                {
                    case "greet":
                    {
                        Console.Write("Enter a name: ");
                        var name = Console.ReadLine();
                        var greeting = myService.Greet(name);
                        Console.WriteLine(greeting);
                    }
                    break;
                    case "add":
                    {
                        Console.Write("Enter a: ");
                        var a = int.Parse(Console.ReadLine());
                        Console.Write("Enter b: ");
                        var b = int.Parse(Console.ReadLine());
                        var sum = myService.Add(a, b);
                        Console.WriteLine(sum);
                    }
                    break;
                    case "aadd":
                    {
                        Console.Write("Enter a: ");
                        var a = int.Parse(Console.ReadLine());
                        Console.Write("Enter b: ");
                        var b = int.Parse(Console.ReadLine());
                        var sum = myService.AddAsync(a, b).Result;
                        Console.WriteLine(sum);
                    }
                    break;
                    case "throw":
                    {
                        try
                        {
                            myService.Throw();
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex);
                        }
                    }
                    break;
                    case "sleep":
                    {
                        try
                        {
                            myService.SleepOneSecond();
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex);
                        }
                    }
                    break;
                    default:
                    {
                        Console.WriteLine("Unkown command");
                    }
                    break;
                }
            }
        }
Пример #5
0
        static void Main(string[] args)
        {
            var topologyLoader = new TopologyLoader("../Topology/topology.txt", Encoding.UTF8, new TopologyParser());
            var client = new RpcClient(topologyLoader, new TimeoutSettings(1, 100));

            var myService = client.GetService<IMyService>();

            var clientLog = new FileLogger("clientlog.txt");

            string line;
            while ((line = Console.ReadLine()) != "exit")
            {
                switch (line)
                {
                    case "void":
                    {
                        myService.Void();
                        Console.WriteLine("Void Complete");
                        break;
                    }
                    case "greet":
                    {
                        Console.Write("Enter a name: ");
                        var name = Console.ReadLine();
                        var greeting = myService.Greet(name);
                        Console.WriteLine(greeting);
                        break;
                    }
                    case "add":
                    {
                        Console.Write("Enter a: ");
                        var a = int.Parse(Console.ReadLine());
                        Console.Write("Enter b: ");
                        var b = int.Parse(Console.ReadLine());
                        var sum = myService.Add(a, b);
                        Console.WriteLine(sum);
                        break;
                    }
                    case "aadd":
                    {
                        Console.Write("Enter a: ");
                        var a = int.Parse(Console.ReadLine());
                        Console.Write("Enter b: ");
                        var b = int.Parse(Console.ReadLine());
                        var sum = myService.AddAsync(a, b).Result;
                        Console.WriteLine(sum);
                        break;
                    }
                    case "throw":
                    {
                        try
                        {
                            myService.Throw();
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex);
                        }
                        break;
                    }
                    case "sleep":
                    {
                        try
                        {
                            myService.SleepOneSecond();
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex);
                        }
                        break;
                    }
                    case "stress":
                    {
                        var globalStart = DateTime.Now;
                        for (int i = 0; i < 10000; i++)
                        {
                            int iLoc = i;
                            var start = DateTime.Now;
                            clientLog.Info(string.Format("{0}:\t{1} start", iLoc, DateTime.Now - globalStart));
                            myService.AddAsync(i, 2 * i).ContinueWith(t => clientLog.Info(string.Format("{0}:\t{1}\t{2}", iLoc, DateTime.Now - globalStart, DateTime.Now - start)));
                        }
                        break;
                    }
                    default:
                    {
                        Console.WriteLine("Unkown command");
                        break;
                    }
                }
            }
        }