1
0
Fork 0
mirror of https://codeberg.org/Mercury-IM/Smack synced 2024-12-22 20:47:57 +01:00

Add Message(String, String) constructor

to make simply Smack examples work, e.g.

Message message = new Message("user@example.org", "Hi, how are you?");
This commit is contained in:
Florian Schmaus 2016-07-24 21:21:21 +02:00
parent aeb385a022
commit 4d7e4b2ab1

View file

@ -27,6 +27,8 @@ import java.util.Set;
import org.jivesoftware.smack.util.TypedCloneable;
import org.jivesoftware.smack.util.XmlStringBuilder;
import org.jxmpp.jid.Jid;
import org.jxmpp.jid.impl.JidCreate;
import org.jxmpp.stringprep.XmppStringprepException;
/**
* Represents XMPP message packets. A message can be one of several types:
@ -101,6 +103,17 @@ public final class Message extends Stanza implements TypedCloneable<Message> {
setBody(body);
}
/**
* Creates a new message to the specified recipient and with the specified body.
*
* @param to the user to send the message to.
* @param body the body of the message.
* @throws XmppStringprepException if 'to' is not a valid XMPP address.
*/
public Message(String to, String body) throws XmppStringprepException {
this(JidCreate.from(to), body);
}
/**
* Copy constructor.
* <p>