public final class ChatManager extends Manager
ChatSession chatSession = xmppSession.getManager(ChatManager.class).createChatSession(chatPartner);
When a contact initiates a new chat session with you, you can listen for it with addChatSessionListener(Consumer).
The listener will be called either if you created the session programmatically as shown above, or if it is created by a contact, i.e. because he or she sent you a chat message.
You should add a Chat.addInboundMessageListener(Consumer) to the chat session in order to listen for messages.
xmppSession.getManager(ChatManager.class).addChatSessionListener(chatSessionEvent -> {
ChatSession chatSession = chatSessionEvent.getChatSession();
chatSession.addInboundMessageListener(e -> {
Message message = e.getMessage();
});
});
| Modifier and Type | Method and Description |
|---|---|
void |
addChatSessionListener(Consumer<ChatSessionEvent> chatSessionListener)
Adds a chat session listener.
|
ChatSession |
createChatSession(Jid chatPartner)
Creates a new chat session and notifies any chat session listeners about it.
|
void |
removeChatSessionListener(Consumer<ChatSessionEvent> chatSessionListener)
Removes a previously added chat session listener.
|
isEnabled, setEnabledpublic void addChatSessionListener(Consumer<ChatSessionEvent> chatSessionListener)
chatSessionListener - The listener.removeChatSessionListener(Consumer)public void removeChatSessionListener(Consumer<ChatSessionEvent> chatSessionListener)
chatSessionListener - The listener.addChatSessionListener(Consumer)public ChatSession createChatSession(Jid chatPartner)
chatPartner - The chat partner.Copyright © 2014–2016 XMPP.rocks. All rights reserved.