Example #1
0
        public static void Main(string[] args)
        {
            Channel channel    = new Channel("127.0.0.1:50051", ChannelCredentials.Insecure);
            var     client     = new PubSub.PubSubClient(channel);
            var     subscriber = new Subscriber(client);

            //do some request/reponse stuff in a thread
            Task.Run(async() =>
            {
                while (true)
                {
                    var reply = client.GetAnEvent(new Empty());
                    Console.WriteLine($"GetAnEvent : {reply}");
                    await Task.Delay(2000);
                }
            }).ConfigureAwait(false).GetAwaiter();

            //do some pub.sub stuff in a thread
            Task.Run(async() =>
            {
                await subscriber.Subscribe(Guid.NewGuid().ToString("N"));
            }).ConfigureAwait(false).GetAwaiter();


            Console.WriteLine("Hit key to unsubscribe");
            Console.ReadLine();

            subscriber.Unsubscribe();

            Console.WriteLine("Unsubscribed...");

            Console.WriteLine("Hit key to exit...");
            Console.ReadLine();
        }
Example #2
0
 public Subscriber(PubSub.PubSubClient pubSubClient)
 {
     _pubSubClient = pubSubClient;
 }