Skip to content

Commit

Permalink
Add convinient constructors for Message and Presence
Browse files Browse the repository at this point in the history
  • Loading branch information
Flowdalic committed Oct 31, 2016
1 parent 9331a4c commit 5a2326a
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,18 @@ public Message(String to, String body) throws XmppStringprepException {
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.
* <p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import org.jivesoftware.smack.util.StringUtils;
import org.jivesoftware.smack.util.TypedCloneable;
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
Expand Down Expand Up @@ -78,6 +79,18 @@ public Presence(Type 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.
*
Expand Down

0 comments on commit 5a2326a

Please sign in to comment.