private static async Task RandomNextDemo()
        {
            var serverIpc = new NamedPipesClient();
            var random    = new Random();
            var server    = new MyNativeLibServer(serverIpc, random);

            server.Start();

            // -----------------

            var clientIpc = new NamedPipesClient(serverIpc.PeerId, serverIpc.OwnId);
            var client    = new NamedPipesRequestResponseClient(clientIpc);

            //-----------------

            while (true)
            {
                var request = new RandomNextRequest()
                {
                    Id = Guid.NewGuid()
                };

                var response = await client.ExecuteAsync <RandomNextResponse>(request).ConfigureAwait(false);

                Console.WriteLine($"[{DateTime.Now}] Next random number is {response.Value}");

                Console.ReadLine();
            }
        }
Exemple #2
0
        private static async Task NamedPipesClientDemo()
        {
            var peerA = new NamedPipesClient();
            var peerB = new NamedPipesClient(peerA.PeerId, peerA.OwnId);

            peerB.Received <DateTime>()
            .Subscribe(date => Console.WriteLine($"Peer B received: {date}."));

            while (true)
            {
                var now = DateTime.Now;
                Console.WriteLine($"Peer A is sending: {now}");

                await peerA.SendAsync(now).ConfigureAwait(false);

                Console.ReadLine();
            }
        }
Exemple #3
0
        private static async Task RandomNextDemo()
        {
            var serverIpc = new NamedPipesClient();
            var random    = new Random();
            var server    = new MyNativeLibServer(serverIpc, random);

            server.Start();

            var clientIpc = new NamedPipesClient(serverIpc.PeerId, serverIpc.OwnId);
            var client    = new MyNativeLibClient(clientIpc);

            while (true)
            {
                var value = await client.NextAsync().ConfigureAwait(false);

                Console.WriteLine($"[{DateTime.Now}] Next random number is {value}");

                Console.ReadLine();
            }
        }
 public NamedPipesRequestResponseClient(NamedPipesClient ipcClient)
 {
     _ipcClient = ipcClient ?? throw new ArgumentNullException(nameof(ipcClient));
 }
Exemple #5
0
 public MyNativeLibServer(NamedPipesClient ipcClient, Random random)
 {
     _ipcClient = ipcClient ?? throw new ArgumentNullException(nameof(ipcClient));
     _random    = random ?? throw new ArgumentNullException(nameof(random));
 }
Exemple #6
0
 public MyNativeLibClient(NamedPipesClient ipcClient)
 {
     _ipcClient = ipcClient ?? throw new ArgumentNullException(nameof(ipcClient));
 }