Here is the other problem I have. I try to filter out the right sort of Packets so I can print out the GroupChat messages. This listed code does not work and does not printout messages I get from the server. (I see them coming on the debug)
Any idea how to filter it right?
Thanks,
(Boy will I be happy if there will be a solution for my login bug too)
I do not register a filter I thought groupChat.addMessageListener(this)takes care of that. I must be missing somthing here.
All I do is: my groupChat client implements PacketListener
Then it have a processPacket(Packet packet)that I listed. Should I register this client with the connection also what filter do I use to get the roster and messages for this room then?
Here’'s the filter that gets used when you use that code:
messageFilter = new AndFilter(messageFilter, new PacketFilter() {
public boolean accept(Packet packet) {
Message msg = (Message)packet;
return msg.getType() == Message.Type.GROUP_CHAT;
}
});
This is NOT what you want if you want to look for presence packets or other types of chat messages. Instead, you should register a packet listener with the appropriate filter directly with the connection. I’'ll try to add more info to the Javadocs to clarify this behavior.
You’'ll be getting packets that are EITHER messages or presence packets. So, you need to do an instanceof check before trying to cast it to one class or another.