Beispiel #1
0
        private static void test(int id, string msg = null)
        {
            // Then configure and connect a client.
            //var clientConfig = ClientConfiguration.LoadFromFile("ClientConfiguration.xml");
            var clientConfig = ClientConfiguration.LocalhostSilo();

            IClusterClient client = new ClientBuilder()
                                    .UseConfiguration(clientConfig).Build();

            client.Connect().Wait();

            Console.WriteLine("Client connected.");

            if (string.IsNullOrEmpty(msg))
            {
                Console.WriteLine("Write some msg.");
                msg = Console.ReadLine();
            }

            GrainClient.Initialize(clientConfig);
            var friend = GrainClient.GrainFactory.GetGrain <IHello>(id);
            var result = friend.SayHello(msg).Result;

            Console.WriteLine(result);

            Chat c   = new Chat();
            var  obj = GrainClient.GrainFactory.CreateObjectReference <IChat>(c).Result;

            friend.Subscribe(obj);

            friend.SendUpdateMessage("456");

            client.Close();
        }
        static async void Run()
        {
            var config = ClientConfiguration.LocalhostSilo(22222);

            GrainClient.Initialize(config);

            var agrain = GrainClient.GrainFactory.GetGrain <IGrains.IBasic>(321);
            var result = await agrain.SayHello("你好");

            Console.WriteLine(result);
        }
Beispiel #3
0
        private async static Task TaskTest()
        {
            var            clientConfig = ClientConfiguration.LocalhostSilo();
            IClusterClient client       = new ClientBuilder()
                                          .UseConfiguration(clientConfig).Build();
            await client.Connect();

            Console.WriteLine("Client connected.");

            await client.GetGrain <ITaskGrain>(0).MyGrainMethod();

            await client.Close();
        }
Beispiel #4
0
        static async Task ConnectAsync()
        {
            try
            {
                var config  = ClientConfiguration.LocalhostSilo();
                var builder = new ClientBuilder().UseConfiguration(config);
                var client  = builder.Build();
                await client.Connect();

                Console.WriteLine("客户端连接成功");
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Beispiel #5
0
        static void Main()
        {
            Console.WriteLine("Make sure that local silo is started. Press Enter to proceed ...");
            Console.ReadLine();

            Console.Write("Enter number of clients: ");
            var numberOfClients = int.Parse(Console.ReadLine() ?? Environment.ProcessorCount.ToString("D"));

            Console.Write("Enter number of repeated pings per client (thousands): ");
            var numberOfRepeatsPerClient = int.Parse(Console.ReadLine() ?? "15");

            var config = ClientConfiguration.LocalhostSilo();

            GrainClient.Initialize(config);

            benchmark = new Benchmark(numberOfClients, numberOfRepeatsPerClient * 1000);
            benchmark.Run();

            Console.ReadLine();
        }
Beispiel #6
0
        static async Task Main(string[] args)
        {
            Log.Logger = new LoggerConfiguration()
                         .WriteTo.Console()
                         .CreateLogger();

            var config = ClientConfiguration.LocalhostSilo();

            config.DefaultTraceLevel = Severity.Warning;
            config.TraceFileName     = null;
            config.TraceToConsole    = false;

            using (var client = new ClientBuilder().UseConfiguration(config).Build())
            {
                await client.Connect();


                Console.WriteLine("Press any key to exit...");
                Console.ReadKey(true);
            }
        }