mirror of
https://github.com/FluuxIO/go-xmpp.git
synced 2024-11-21 18:12:00 -08:00
Decode query
This commit is contained in:
parent
ec95020ac2
commit
e14f58d9a9
@ -19,8 +19,10 @@ func main() {
|
|||||||
|
|
||||||
switch p := packet.(type) {
|
switch p := packet.(type) {
|
||||||
case xmpp.IQ:
|
case xmpp.IQ:
|
||||||
fmt.Println("IQ received: ", p)
|
switch p.Payload.(type) {
|
||||||
fmt.Println("IQ type:", p.Type)
|
case *xmpp.Query:
|
||||||
|
fmt.Println("Received query:", p.Type)
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
fmt.Println("Packet unhandled packet:", packet)
|
fmt.Println("Packet unhandled packet:", packet)
|
||||||
}
|
}
|
||||||
|
11
iq.go
11
iq.go
@ -73,6 +73,8 @@ func (iq *IQ) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error {
|
|||||||
switch tt.Name.Space + " " + tt.Name.Local {
|
switch tt.Name.Space + " " + tt.Name.Local {
|
||||||
case "urn:ietf:params:xml:ns:xmpp-bind bind":
|
case "urn:ietf:params:xml:ns:xmpp-bind bind":
|
||||||
p = new(bindBind)
|
p = new(bindBind)
|
||||||
|
case "http://jabber.org/protocol/disco#items query":
|
||||||
|
p = new(Query)
|
||||||
case "urn:xmpp:iot:control set":
|
case "urn:xmpp:iot:control set":
|
||||||
p = new(iot.ControlSet)
|
p = new(iot.ControlSet)
|
||||||
// TODO: Add a default Type that passes RawXML
|
// TODO: Add a default Type that passes RawXML
|
||||||
@ -114,3 +116,12 @@ func (iq *IQ) XMPPFormat() string {
|
|||||||
iq.To, iq.Type, iq.Id,
|
iq.To, iq.Type, iq.Id,
|
||||||
iq.RawXML)
|
iq.RawXML)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ============================================================================
|
||||||
|
// IQ Query subelement
|
||||||
|
|
||||||
|
type Query struct {
|
||||||
|
XMLName xml.Name `xml:"http://jabber.org/protocol/disco#items query"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (*Query) IsIQPayload() {}
|
||||||
|
Loading…
Reference in New Issue
Block a user