mirror of
https://github.com/vanitasvitae/Smack.git
synced 2024-11-22 20:12:07 +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:
parent
6551c8edb9
commit
0d156ee0a6
1 changed files with 15 additions and 6 deletions
|
@ -80,9 +80,12 @@ public class GroupChat {
|
||||||
private PacketCollector messageCollector;
|
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
|
* @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 the hostname at which the multi-user chat
|
||||||
* service is running.
|
* service is running.
|
||||||
|
@ -93,6 +96,12 @@ public class GroupChat {
|
||||||
// Create a collector for all incoming messages.
|
// Create a collector for all incoming messages.
|
||||||
messageFilter = new AndFilter(new FromContainsFilter(room),
|
messageFilter = new AndFilter(new FromContainsFilter(room),
|
||||||
new PacketTypeFilter(Message.class));
|
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);
|
messageCollector = connection.createPacketCollector(messageFilter);
|
||||||
// Create a listener for all presence updates.
|
// Create a listener for all presence updates.
|
||||||
presenceFilter = new AndFilter(new FromContainsFilter(room),
|
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
|
* @param listener a packet listener that will be notified of any presence packets
|
||||||
* sent to the group chat.
|
* sent to the group chat.
|
||||||
*/
|
*/
|
||||||
public void addParticipantListner(PacketListener listener) {
|
public void addParticipantListener(PacketListener listener) {
|
||||||
connection.addPacketListener(listener, presenceFilter);
|
connection.addPacketListener(listener, presenceFilter);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -235,7 +244,7 @@ public class GroupChat {
|
||||||
* @throws XMPPException if sending the message fails.
|
* @throws XMPPException if sending the message fails.
|
||||||
*/
|
*/
|
||||||
public void sendMessage(String text) throws XMPPException {
|
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);
|
message.setBody(text);
|
||||||
connection.sendPacket(message);
|
connection.sendPacket(message);
|
||||||
}
|
}
|
||||||
|
@ -246,7 +255,7 @@ public class GroupChat {
|
||||||
* @return a new Message addressed to the chat room.
|
* @return a new Message addressed to the chat room.
|
||||||
*/
|
*/
|
||||||
public Message createMessage() {
|
public Message createMessage() {
|
||||||
return new Message(room, Message.GROUP_CHAT);
|
return new Message(room, Message.Type.GROUP_CHAT);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in a new issue