public class GroupChat
extends java.lang.Object
XMPPConnection.createGroupChat(String)
Constructor and Description |
---|
GroupChat(XMPPConnection connection,
java.lang.String room)
Creates a new group chat with the specified connection and room name.
|
Modifier and Type | Method and Description |
---|---|
void |
addMessageListener(PacketListener listener)
Adds a packet listener that will be notified of any new messages in the
group chat.
|
void |
addParticipantListener(PacketListener listener)
Adds a packet listener that will be notified of any new Presence packets
sent to the group chat.
|
Message |
createMessage()
Creates a new Message to send to the chat room.
|
void |
finalize() |
java.lang.String |
getNickname()
Returns the nickname that was used to join the room, or null if not
currently joined.
|
int |
getParticipantCount()
Returns the number of participants in the group chat.
|
java.util.Iterator |
getParticipants()
Returns an Iterator (of Strings) for the list of fully qualified participants
in the group chat.
|
java.lang.String |
getRoom()
Returns the name of the room this GroupChat object represents.
|
boolean |
isJoined()
Returns true if currently in the group chat (after calling the
join(String) method. |
void |
join(java.lang.String nickname)
Joins the chat room using the specified nickname.
|
void |
join(java.lang.String nickname,
long timeout)
Joins the chat room using the specified nickname.
|
void |
leave()
Leave the chat room.
|
Message |
nextMessage()
Returns the next available message in the chat.
|
Message |
nextMessage(long timeout)
Returns the next available message in the chat.
|
Message |
pollMessage()
Polls for and returns the next message, or null if there isn't
a message immediately available.
|
void |
sendMessage(Message message)
Sends a Message to the chat room.
|
void |
sendMessage(java.lang.String text)
Sends a message to the chat room.
|
public GroupChat(XMPPConnection connection, java.lang.String room)
join
the chat room. On some server implementations,
the room will not be created until the first person joins it.Most XMPP servers use a sub-domain for the chat service (eg chat.example.com for the XMPP server example.com). You must ensure that the room address you're trying to connect to includes the proper chat sub-domain.
connection
- the XMPP connection.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.public java.lang.String getRoom()
public void join(java.lang.String nickname) throws XMPPException
nickname
- the nickname to use.XMPPException
- if an error occurs joining the room. In particular, a
409 error can occur if someone is already in the group chat with the same
nickname.public void join(java.lang.String nickname, long timeout) throws XMPPException
nickname
- the nickname to use.timeout
- the number of milleseconds to wait for a reply from the
group chat that joining the room succeeded.XMPPException
- if an error occurs joining the room. In particular, a
409 error can occur if someone is already in the group chat with the same
nickname.public boolean isJoined()
join(String)
method.public void leave()
public java.lang.String getNickname()
public int getParticipantCount()
Note: this value will only be accurate after joining the group chat, and may fluctuate over time. If you query this value directly after joining the group chat it may not be accurate, as it takes a certain amount of time for the server to send all presence packets to this client.
public java.util.Iterator getParticipants()
StringUtils.parseResource(String)
method.
Note: this value will only be accurate after joining the group chat, and may
fluctuate over time.public void addParticipantListener(PacketListener listener)
listener
- a packet listener that will be notified of any presence packets
sent to the group chat.public void sendMessage(java.lang.String text) throws XMPPException
text
- the text of the message to send.XMPPException
- if sending the message fails.public Message createMessage()
public void sendMessage(Message message) throws XMPPException
message
- the message.XMPPException
- if sending the message fails.public Message pollMessage()
nextMessage()
method since it's non-blocking.
In other words, the method call will always return immediately, whereas the
nextMessage method will return only when a message is available (or after
a specific timeout).public Message nextMessage()
public Message nextMessage(long timeout)
timeout
- the maximum amount of time to wait for the next message.public void addMessageListener(PacketListener listener)
listener
- a packet listener.public void finalize() throws java.lang.Throwable
finalize
in class java.lang.Object
java.lang.Throwable
Copyright © 2003 Jive Software.