|
Smack | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.jivesoftware.smack.GroupChat
public class GroupChat
A GroupChat is a conversation that takes place among many users in a virtual room. When joining a group chat, you specify a nickname, which is the identity that other chat room users see.
XMPPConnection.createGroupChat(String)
Constructor Summary | |
---|---|
GroupChat(XMPPConnection connection,
String room)
Creates a new group chat with the specified connection and room name. |
Method Summary | |
---|---|
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()
|
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. |
Iterator |
getParticipants()
Returns an Iterator (of Strings) for the list of fully qualified participants in the group chat. |
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(String nickname)
Joins the chat room using the specified nickname. |
void |
join(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(String text)
Sends a message to the chat room. |
Methods inherited from class java.lang.Object |
---|
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public GroupChat(XMPPConnection connection, 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.Method Detail |
---|
public String getRoom()
public void join(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(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 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 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(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 Throwable
finalize
in class Object
Throwable
|
Smack | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |