Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            var authenticator = new NullClientAuthenticator();
            var client        = Client.Create("localhost", 9091);

            client.OnDataReceived += OnDataReceived;

            Console.WriteLine("Enter an empty feed or topic to quit");
            while (true)
            {
                Console.Write("Feed: ");
                var feed = Console.ReadLine();
                if (string.IsNullOrWhiteSpace(feed))
                {
                    break;
                }

                Console.Write("Topic: ");
                var topic = Console.ReadLine();
                if (string.IsNullOrWhiteSpace(topic))
                {
                    break;
                }

                Console.WriteLine($"Subscribing to feed \"{feed}\" with topic \"{topic}\"");
                client.AddSubscription(feed, topic);
            }

            client.Dispose();
        }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            var authenticator    = new NullClientAuthenticator();
            var client           = Client.Create("localhost", 9091);
            var cachingPublisher = new CachingPublisher(client);

            StartPublishing(cachingPublisher);
            System.Threading.Thread.CurrentThread.Join();
        }
Ejemplo n.º 3
0
        static void Main(string[] args)
        {
            var authenticator = new NullClientAuthenticator();
            var client        = Client.Create("localhost", 9091);

            Console.WriteLine("Enter the feed and topic to publish on, then the message to send.");
            Console.WriteLine("Press ENTER to quit");
            while (true)
            {
                Console.Write("Feed: ");
                var feed = Console.ReadLine();
                if (string.IsNullOrWhiteSpace(feed))
                {
                    break;
                }

                Console.Write("Topic: ");
                var topic = Console.ReadLine();
                if (string.IsNullOrWhiteSpace(topic))
                {
                    break;
                }

                Console.Write("Message: ");
                var message = Console.ReadLine();
                if (string.IsNullOrWhiteSpace(topic))
                {
                    break;
                }

                var data = new[]
                {
                    new DataPacket(null, Encoding.UTF8.GetBytes(message))
                };

                Console.WriteLine($"Publishing on feed \"{feed}\" topic \"{topic}\" message \"{message}\"");
                client.Publish(feed, topic, true, data);
            }

            client.Dispose();
        }
Ejemplo n.º 4
0
        static void Main(string[] args)
        {
            var authenticator = new NullClientAuthenticator();
            var client        = Client.Create("localhost", 9091);

            client.OnForwardedSubscription += OnForwardedSubscription;

            Console.WriteLine("Enter the feed to be notified on.");
            Console.WriteLine("Press ENTER to quit");
            while (true)
            {
                Console.Write("Feed: ");
                var feed = Console.ReadLine();
                if (string.IsNullOrWhiteSpace(feed))
                {
                    break;
                }

                Console.WriteLine($"Requesting notifications for subscriptions on feed \"{feed}\".");
                client.AddNotification(feed);
            }

            client.Dispose();
        }