示例#1
0
        public async static Task <List <portCallMessage> > getEvents(string callID)
        {
            string        date    = "2000-04-03T14:00:34Z";
            List <Filter> filters = new List <Filter>();
            Filter        filter1 = new Filter(FilterType.PORT_CALL, callID);

            filters.Add(filter1);

            string q = await QueueHandler.createFilteredQueue(filters, date);

            var list = await QueueHandler.pollQueue(q);


            return(list);
        }
        public static async Task <List <string> > subscribe(string portCallId)
        {
            List <Filter> filter = new List <Filter>();

            filter.Add(new Filter(FilterType.PORT_CALL, portCallId));

            Console.WriteLine("Creating queue with Filter PORTCALL, " + portCallId + "...");

            string queueId = await QueueHandler.createFilteredQueue(filter);

            Console.WriteLine("Queue created with id: " + queueId + ", adding to subscribed list...");

            subscribedQueues.Add(queueId);

            Console.WriteLine("Added " + queueId + " to list of subscriptions");

            startTimer();

            return(subscribedQueues);
        }
        private static async void OnTimedEvent(object source, ElapsedEventArgs e)
        {
            Console.WriteLine("Looking for new messages...");
            List <portCallMessage> result = new List <portCallMessage>();

            foreach (string sub in subscribedQueues)
            {
                List <portCallMessage> tmp = await QueueHandler.pollQueue(sub);

                foreach (portCallMessage pcm in tmp)
                {
                    Console.WriteLine("Update detected on PortCall: " + pcm.portCallId);
                    result.Add(pcm);
                }
            }

            if (result.Count == 0)
            {
                Console.WriteLine("No new updates");
            }
        }