1
0
Fork 0
mirror of https://github.com/vanitasvitae/Smack.git synced 2024-11-22 12:02:05 +01:00

Add convinient constructors for Message and Presence

This commit is contained in:
Florian Schmaus 2016-10-31 12:24:03 +01:00
parent 9331a4c677
commit 5a2326a856
2 changed files with 25 additions and 0 deletions

View file

@ -114,6 +114,18 @@ public final class Message extends Stanza implements TypedCloneable<Message> {
this(JidCreate.from(to), body); this(JidCreate.from(to), body);
} }
/**
* Creates a new message with the specified recipient and extension element.
*
* @param to
* @param extensionElement
* @since 4.2
*/
public Message(Jid to, ExtensionElement extensionElement) {
this(to);
addExtension(extensionElement);
}
/** /**
* Copy constructor. * Copy constructor.
* <p> * <p>

View file

@ -24,6 +24,7 @@ import org.jivesoftware.smack.util.Objects;
import org.jivesoftware.smack.util.StringUtils; import org.jivesoftware.smack.util.StringUtils;
import org.jivesoftware.smack.util.TypedCloneable; import org.jivesoftware.smack.util.TypedCloneable;
import org.jivesoftware.smack.util.XmlStringBuilder; import org.jivesoftware.smack.util.XmlStringBuilder;
import org.jxmpp.jid.Jid;
/** /**
* Represents XMPP presence packets. Every presence stanza(/packet) has a type, which is one of * Represents XMPP presence packets. Every presence stanza(/packet) has a type, which is one of
@ -78,6 +79,18 @@ public final class Presence extends Stanza implements TypedCloneable<Presence> {
setType(type); setType(type);
} }
/**
* Creates a new presence with the given type and using the given XMPP address as recipient.
*
* @param to the recipient.
* @param type the type.
* @since 4.2
*/
public Presence(Jid to, Type type) {
this(type);
setTo(to);
}
/** /**
* Creates a new presence update with a specified status, priority, and mode. * Creates a new presence update with a specified status, priority, and mode.
* *