diff --git a/documentation/messaging.html b/documentation/messaging.html index 35af39c74..457c8d6a7 100644 --- a/documentation/messaging.html +++ b/documentation/messaging.html @@ -82,6 +82,40 @@ newChat.sendMessage(newMessage); } + +
+ Incoming Chat +
+ +When chats are prompted by another user, the setup is slightly different since +you are receiving a chat message first. Instead of explicitly creating a chat to send +messages, you need to register to handle newly created Chat instances when the ChatManager +creates them. + + +The ChatManager will already find a matching chat (by thread id) and if none exists, then it +will create a new one that does match. To get this new chat, you have to register to be +notified when it happens. You can register a message listener to receive all future messages as +part of this handler.+ +
// Assume we've created a Connection name "connection". +ChatManager chatmanager = connection.getChatManager().addChatListener( + new ChatManagerListener() { + @Override + public void chatCreated(Chat chat, boolean createdLocally) + { + if (!createdLocally) + chat.addMessageListener(new MyNewMessageListener());; + } + }); ++