diff --git a/xmpp.go b/xmpp.go
index 839b483..77fc909 100644
--- a/xmpp.go
+++ b/xmpp.go
@@ -1128,8 +1128,50 @@ func (c *Client) SendOrg(org string) (n int, err error) {
return fmt.Fprint(c.stanzaWriter, org+"\n")
}
+// SendPresence sends Presence wrapped inside XMPP presence stanza.
func (c *Client) SendPresence(presence Presence) (n int, err error) {
- return fmt.Fprintf(c.stanzaWriter, "\n", xmlEscape(presence.From), xmlEscape(presence.To))
+ // Forge opening presence tag
+ var buf string = ""
+
+ // TODO: there may be optional tag "priority", but former presence type does not take this into account
+ // so either we must follow std, change type xmpp.Presence and break backward compatibility
+ // or leave it as-is and potentially break client software
+
+ if presence.Show != "" {
+ // https://www.ietf.org/rfc/rfc3921.txt 2.2.2.1, show can be only
+ // away, chat, dnd, xa
+ switch presence.Show {
+ case "away", "chat", "dnd", "xa":
+ buf = buf + fmt.Sprintf("%s", xmlEscape(presence.Show))
+ }
+ }
+
+ if presence.Status != "" {
+ buf = buf + fmt.Sprintf("%s", xmlEscape(presence.Status))
+ }
+
+ buf = buf + ""
+
+ return fmt.Fprint(c.stanzaWriter, buf)
}
// SendKeepAlive sends a "whitespace keepalive" as described in chapter 4.6.1 of RFC6120.