Methods Summary |
---|
public synchronized void | addMessageListener(MessageListener listener)Adds a MessageListener so that it can be notified of any new message in
this session.
if ((listener != null) && !mListeners.contains(listener)) {
mListeners.add(listener);
}
|
public java.util.List | getHistoryMessages()Returns a unmodifiable list of the history messages in this session.
return Collections.unmodifiableList(mHistoryMessages);
|
public ImEntity | getParticipant()
return mParticipant;
|
public void | onReceiveMessage(Message msg)Called by ChatSessionManager when received a message of the ChatSession.
All the listeners registered in this session will be notified.
mHistoryMessages.add(msg);
for (MessageListener listener : mListeners) {
listener.onIncomingMessage(this, msg);
}
|
public void | onSendMessageError(java.lang.String msgId, ImErrorInfo error)
for(Message msg : mHistoryMessages){
if(msgId.equals(msg.getID())){
onSendMessageError(msg, error);
return;
}
}
Log.i("ChatSession", "Message has been removed when we get delivery error:"
+ error);
|
public void | onSendMessageError(Message message, ImErrorInfo error)Called by ChatSessionManager when an error occurs to send a message.
for (MessageListener listener : mListeners) {
listener.onSendMessageError(this, message, error);
}
|
public synchronized void | removeMessageListener(MessageListener listener)Removes a listener from this session.
mListeners.remove(listener);
|
public void | sendMessageAsync(java.lang.String text)Sends a text message to other participant(s) in this session
asynchronously.
TODO: more docs on async callbacks.
Message message = new Message(text);
sendMessageAsync(message);
|
public void | sendMessageAsync(Message msg)Sends a message to other participant(s) in this session asynchronously.
TODO: more docs on async callbacks.
msg.setTo(mParticipant.getAddress());
mHistoryMessages.add(msg);
mManager.sendMessageAsync(this, msg);
|
public void | setParticipant(ImEntity participant)
mParticipant = participant;
|