1
0
Fork 0
mirror of https://github.com/vanitasvitae/Smack.git synced 2024-12-24 03:27:59 +01:00

Fixed message filter to only accept group chat messages, fixed method name.

git-svn-id: http://svn.igniterealtime.org/svn/repos/smack/trunk@1921 b35dd754-fafc-0310-a699-88a17e54d16e
This commit is contained in:
Matt Tucker 2003-05-07 19:10:06 +00:00 committed by mtucker
parent 6551c8edb9
commit 0d156ee0a6

View file

@ -80,9 +80,12 @@ public class GroupChat {
private PacketCollector messageCollector;
/**
* Creates a new group chat with the specified connection and room name.
* Creates a new group chat with the specified connection and room name. Note: no
* information is sent to or received from the server until you attempt to join the
* chat room. On some server implementations, the room will not be created until the
* first person joins it.
*
* @param connection
* @param connection the XMPP Connection.
* @param room the name of the room in the form "roomName@service", where
* "service" is the hostname at which the multi-user chat
* service is running.
@ -93,6 +96,12 @@ public class GroupChat {
// Create a collector for all incoming messages.
messageFilter = new AndFilter(new FromContainsFilter(room),
new PacketTypeFilter(Message.class));
messageFilter = new AndFilter(messageFilter, new PacketFilter() {
public boolean accept(Packet packet) {
Message msg = (Message)packet;
return msg.getType() == Message.Type.GROUP_CHAT;
}
});
messageCollector = connection.createPacketCollector(messageFilter);
// Create a listener for all presence updates.
presenceFilter = new AndFilter(new FromContainsFilter(room),
@ -224,7 +233,7 @@ public class GroupChat {
* @param listener a packet listener that will be notified of any presence packets
* sent to the group chat.
*/
public void addParticipantListner(PacketListener listener) {
public void addParticipantListener(PacketListener listener) {
connection.addPacketListener(listener, presenceFilter);
}
@ -235,7 +244,7 @@ public class GroupChat {
* @throws XMPPException if sending the message fails.
*/
public void sendMessage(String text) throws XMPPException {
Message message = new Message(room, Message.GROUP_CHAT);
Message message = new Message(room, Message.Type.GROUP_CHAT);
message.setBody(text);
connection.sendPacket(message);
}
@ -246,7 +255,7 @@ public class GroupChat {
* @return a new Message addressed to the chat room.
*/
public Message createMessage() {
return new Message(room, Message.GROUP_CHAT);
return new Message(room, Message.Type.GROUP_CHAT);
}
/**
@ -306,4 +315,4 @@ public class GroupChat {
public void addMessageListener(PacketListener listener) {
connection.addPacketListener(listener, messageFilter);
}
}
}