diff --git a/cmd/xmpp_component/xmpp_component.go b/cmd/xmpp_component/xmpp_component.go index 3a6fb4b..7b794c2 100644 --- a/cmd/xmpp_component/xmpp_component.go +++ b/cmd/xmpp_component/xmpp_component.go @@ -19,9 +19,11 @@ func main() { switch p := packet.(type) { case xmpp.IQ: - switch p.Payload.(type) { - case *xmpp.Query: - fmt.Println("Received query:", p.Type) + switch inner := p.Payload.(type) { + case *xmpp.Node: + fmt.Println("Node:", inner.XMLName.Space, inner.XMLName.Local) + default: + fmt.Println("default") } default: fmt.Println("Packet unhandled packet:", packet) diff --git a/iq.go b/iq.go index 582bcae..63667f1 100644 --- a/iq.go +++ b/iq.go @@ -73,11 +73,10 @@ func (iq *IQ) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error { switch tt.Name.Space + " " + tt.Name.Local { case "urn:ietf:params:xml:ns:xmpp-bind bind": p = new(bindBind) - case "http://jabber.org/protocol/disco#items query": - p = new(Query) case "urn:xmpp:iot:control set": p = new(iot.ControlSet) - // TODO: Add a default Type that passes RawXML + default: + p = new(Node) } if p != nil { err = d.DecodeElement(p, &tt) @@ -118,10 +117,12 @@ func (iq *IQ) XMPPFormat() string { } // ============================================================================ -// IQ Query subelement +// Genery IQ Node -type Query struct { - XMLName xml.Name `xml:"http://jabber.org/protocol/disco#items query"` +type Node struct { + XMLName xml.Name + Content []byte `xml:",innerxml"` + Nodes []Node `xml:",any"` } -func (*Query) IsIQPayload() {} +func (*Node) IsIQPayload() {}