1
0
Fork 0
mirror of https://codeberg.org/Mercury-IM/Smack synced 2024-11-22 14:22:05 +01:00

Merge pull request #223 from fuentesj11/update-docs5

Update/Edit messaging.md
This commit is contained in:
Florian Schmaus 2018-04-03 07:48:44 +02:00 committed by GitHub
commit b472ba0dd2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -18,7 +18,7 @@ and then send them a text message:
``` ```
// Assume we've created an XMPPConnection name "connection"._ // Assume we've created an XMPPConnection name "connection"._
ChatManager chatManager = ChatManager.getInstanceFor(connection); ChatManager chatManager = ChatManager.getInstanceFor(connection);
chatManager.addListener(new IncomingChatMessageListener() { chatManager.addIncomingListener(new IncomingChatMessageListener() {
@Override @Override
void newIncomingMessage(EntityBareJid from, Message message, Chat chat) { void newIncomingMessage(EntityBareJid from, Message message, Chat chat) {
System.out.println("New message from " + from + ": " + message.getBody()); System.out.println("New message from " + from + ": " + message.getBody());
@ -26,14 +26,14 @@ chatManager.addListener(new IncomingChatMessageListener() {
}); });
EntityBareJid jid = JidCreate.entityBareFrom("jsmith@jivesoftware.com"); EntityBareJid jid = JidCreate.entityBareFrom("jsmith@jivesoftware.com");
Chat chat = chatManager.chatWith(jid); Chat chat = chatManager.chatWith(jid);
chat.sendMessage("Howdy!"); chat.send("Howdy!");
} }
``` ```
The `Chat.sendMessage(String)` method is a convenience method that creates a The `Chat.send(String)` method is a convenience method that creates a
Message object, sets the body using the String parameter, then sends the Message object, sets the body using the String parameter, then sends the
message. In the case that you wish to set additional values on a Message message. In the case that you wish to set additional values on a Message
before sending it, use before sending it, use the
`Chat.send(Message)` method, as in the following code snippet: `Chat.send(Message)` method, as in the following code snippet:
``` ```