PubSub protocol support (#142)

* PubSub protocol support
Added support for :
- XEP-0050   (Command))
- XEP-0060   (PubSub)
- XEP-0004   (Forms)

Fixed the NewClient function by adding parsing of the domain from the JID if no domain is provided in transport config.
Updated xmpp_jukebox example

* Delete useless pubsub errors

* README.md update
Fixed import in echo example

* Typo

* Fixed raw send on client example

* Fixed jukebox example and added a README.md
This commit is contained in:
remicorniere
2020-01-09 14:33:11 +00:00
committed by Jérôme Sautret
parent 6e2ba9ca57
commit 947fcf0432
29 changed files with 3375 additions and 51 deletions

View File

@@ -3,6 +3,7 @@ package stanza
import (
"encoding/xml"
"strconv"
"strings"
)
// ============================================================================
@@ -53,10 +54,19 @@ func (x *Err) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error {
}
textName := xml.Name{Space: "urn:ietf:params:xml:ns:xmpp-stanzas", Local: "text"}
if elt.XMLName == textName {
// TODO : change the pubsub handling ? It kind of dilutes the information
// Handles : 6.1.3.11 Node Has Moved for XEP-0060 (PubSubGeneric)
goneName := xml.Name{Space: "urn:ietf:params:xml:ns:xmpp-stanzas", Local: "gone"}
if elt.XMLName == textName || // Regular error text
elt.XMLName == goneName { // Gone text for pubsub
x.Text = elt.Content
} else if elt.XMLName.Space == "urn:ietf:params:xml:ns:xmpp-stanzas" {
x.Reason = elt.XMLName.Local
} else if elt.XMLName.Space == "urn:ietf:params:xml:ns:xmpp-stanzas" ||
elt.XMLName.Space == "http://jabber.org/protocol/pubsub#errors" {
if strings.TrimSpace(x.Reason) != "" {
x.Reason = strings.Join([]string{elt.XMLName.Local}, ":")
} else {
x.Reason = elt.XMLName.Local
}
}
case xml.EndElement: