Decode query

This commit is contained in:
Mickael Remond 2018-01-13 19:14:26 +01:00
parent ec95020ac2
commit e14f58d9a9
No known key found for this signature in database
GPG Key ID: E6F6045D79965AA3
2 changed files with 15 additions and 2 deletions

View File

@ -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)
}

11
iq.go
View File

@ -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() {}