powered by Jive Software

Message listener vs. collector in Chat/GroupChat/MultiUserChat

I’‘m a little confused about the message interface for Chat, GroupChat, and MultiUserChat. I can call nextMessage() to retrieve messages from the queue, or I can set up a listener with addMessageListener(). If I do the latter, though, the messages will still get queued, and unless I also call nextMessage() every time a message arrives, the queue will fill up indefinitely. (Well, only until 2^16 messages, I guess, since it’‘s a PacketCollector.) Is this right? Is the idea that nextMessage() should always be used to retrieve messages, even if they’‘ve already been processed by a listener? It seems like there should be a way to cancel the default collector if I plan to use a listener instead of nextMessage(), but maybe I’'m misunderstanding the intended use cases.




I think you have a good point. You should definitely be able to use just a listener and not incur penalties for ignoring the collector. I’‘ll file a bug in the issue tracker. As a workaround until we have a fix, I’'d recommend calling nextMessage every time your listener gets notified.