Beispiel #1
0
        public void listen()
        {
            IDestination dest = session.GetDestination(queue);

            using (IMessageConsumer consumer = session.CreateConsumer(dest))
            {
                Console.WriteLine("i'm listening . . . ");
                IMessage text;
                while (true)
                {
                    text = consumer.Receive();

                    if (text != null)
                    {
                        ITextMessage message = text as ITextMessage;
                        if (!string.IsNullOrEmpty(message.Text))
                        {
                            Console.WriteLine(message.Text);
                            ChatMessage cmsg = JsonConvert.DeserializeObject <ChatMessage>(message.Text);
                            finestra.updateCollection(cmsg);
                        }
                        else
                        {
                            Console.Write("VUOTO!");
                        }
                    }
                }
            }
        }
Beispiel #2
0
        public void listen()
        {
            c.Start(); //NEEDED TO START THE CONNECTION TO ACTIVEMQ
            IDestination dest = session.GetDestination(queue);

            using (IMessageConsumer consumer = session.CreateConsumer(dest)) //create the stream to dequeue messages
            {
                IMessage text;
                while (true)
                {
                    text = consumer.Receive(); //dequeue dest
                    if (text != null)
                    {
                        ITextMessage message = text as ITextMessage;
                        if (!string.IsNullOrEmpty(message.Text))
                        {
                            ChatMessage cmsg = JsonConvert.DeserializeObject <ChatMessage>(message.Text); //RETRIVE OBJECT FROM JSON STRING
                            finestra.updateCollection(cmsg);
                        }
                    }
                }
            }
        }