|
Smack | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.jivesoftware.smack.Chat
public class Chat
A chat is a series of messages sent between two users. Each chat has a unique thread ID, which is used to track which messages are part of a particular conversation. Some messages are sent without a thread ID, and some clients don't send thread IDs at all. Therefore, if a message without a thread ID arrives it is routed to the most recently created Chat with the message sender.
XMPPConnection.createChat(String)| Constructor Summary | |
|---|---|
Chat(XMPPConnection connection,
String participant)
Creates a new chat with the specified user. |
|
Chat(XMPPConnection connection,
String participant,
String threadID)
Creates a new chat with the specified user and thread ID. |
|
| Method Summary | |
|---|---|
void |
addMessageListener(PacketListener listener)
Adds a packet listener that will be notified of any new messages in the chat. |
Message |
createMessage()
Creates a new Message to the chat participant. |
void |
finalize()
|
String |
getParticipant()
Returns the name of the user the chat is with. |
String |
getThreadID()
Returns the thread id associated with this chat, which corresponds to the thread field of XMPP messages. |
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 other chat participant. |
void |
sendMessage(String text)
Sends the specified text as a message to the other chat participant. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public Chat(XMPPConnection connection,
String participant)
connection - the connection the chat will use.participant - the user to chat with.
public Chat(XMPPConnection connection,
String participant,
String threadID)
connection - the connection the chat will use.participant - the user to chat with.threadID - the thread ID to use.| Method Detail |
|---|
public String getThreadID()
public String getParticipant()
public void sendMessage(String text)
throws XMPPException
Message message = chat.createMessage();
message.setBody(messageText);
chat.sendMessage(message);
text - the text to send.
XMPPException - if sending the message fails.public Message createMessage()
sendMessage(Message)
public void sendMessage(Message message)
throws XMPPException
createMessage
method.
message - the message to send.
XMPPException - if an error occurs sending the message.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 ObjectThrowable
|
Smack | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||