From e14f58d9a991a129ae3811ed2c79116d4c2725f3 Mon Sep 17 00:00:00 2001 From: Mickael Remond Date: Sat, 13 Jan 2018 19:14:26 +0100 Subject: [PATCH] Decode query --- cmd/xmpp_component/xmpp_component.go | 6 ++++-- iq.go | 11 +++++++++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/cmd/xmpp_component/xmpp_component.go b/cmd/xmpp_component/xmpp_component.go index 58f9227..3a6fb4b 100644 --- a/cmd/xmpp_component/xmpp_component.go +++ b/cmd/xmpp_component/xmpp_component.go @@ -19,8 +19,10 @@ func main() { switch p := packet.(type) { case xmpp.IQ: - fmt.Println("IQ received: ", p) - fmt.Println("IQ type:", p.Type) + switch p.Payload.(type) { + case *xmpp.Query: + fmt.Println("Received query:", p.Type) + } default: fmt.Println("Packet unhandled packet:", packet) } diff --git a/iq.go b/iq.go index 97438ba..582bcae 100644 --- a/iq.go +++ b/iq.go @@ -73,6 +73,8 @@ 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 @@ -114,3 +116,12 @@ func (iq *IQ) XMPPFormat() string { iq.To, iq.Type, iq.Id, iq.RawXML) } + +// ============================================================================ +// IQ Query subelement + +type Query struct { + XMLName xml.Name `xml:"http://jabber.org/protocol/disco#items query"` +} + +func (*Query) IsIQPayload() {}