Exemple #1
0
        private static async Task ReceiveNotificationsAsync(IClientChannel channel, CancellationToken cancellationToken)
        {
            try
            {
                while (!cancellationToken.IsCancellationRequested)
                {
                    var notification = await channel.ReceiveNotificationAsync(cancellationToken);

                    System.Console.ForegroundColor = ConsoleColor.Blue;
                    System.Console.WriteLine();

                    if (notification.Reason != null)
                    {
                        System.Console.WriteLine("Notification received - From: {0} - Id: {1} - Event: {2} - Reason: {3}",
                                                 notification.From, notification.Id, notification.Event, notification.Reason);
                    }
                    else
                    {
                        System.Console.WriteLine("Notification received - From: {0} - Id: {1} - Event: {2}",
                                                 notification.From, notification.Id, notification.Event);
                    }

                    System.Console.ResetColor();
                }
            }
            catch (OperationCanceledException)
            {
                return;
            }
        }
Exemple #2
0
        private async Task ListenNotificationsAsync()
        {
            while (!_cancellationTokenSource.IsCancellationRequested)
            {
                var notification = await _clientChannel.ReceiveNotificationAsync(_cancellationTokenSource.Token);

                ProcessNotification(notification);
            }
        }
Exemple #3
0
        static async Task ConsumeNotificationsAsync(IClientChannel clientChannel, CancellationToken cancellationToken)
        {
            while (!cancellationToken.IsCancellationRequested)
            {
                var notification = await clientChannel.ReceiveNotificationAsync(cancellationToken);

                Console.ForegroundColor = ConsoleColor.DarkBlue;
                Console.WriteLine("Notification with id {0} received from '{1}' - Event: {2}", notification.Id, notification.From ?? clientChannel.RemoteNode, notification.Event);
                Console.ResetColor();
            }
        }
Exemple #4
0
		private static async Task ReceiveNotificationsAsync(IClientChannel channel, CancellationToken cancellationToken)
		{
			try
			{
				while (!cancellationToken.IsCancellationRequested)
				{
					var notification = await channel.ReceiveNotificationAsync (cancellationToken);

					System.Console.ForegroundColor = ConsoleColor.Blue;
					System.Console.WriteLine ();

					if (notification.Reason != null)
					{
						System.Console.WriteLine ("Notification received - From: {0} - Id: {1} - Event: {2} - Reason: {3}", 
							notification.From, notification.Id, notification.Event, notification.Reason);
					}
					else
					{
						System.Console.WriteLine ("Notification received - From: {0} - Id: {1} - Event: {2}", 
							notification.From, notification.Id, notification.Event);
					}

					System.Console.ResetColor ();
				}
			}
			catch (OperationCanceledException)
			{
				return;
			}
		}