go-xmpp/cmd/xmpp_component/xmpp_component.go
Mickael Remond e14f58d9a9
Decode query
2018-01-13 19:14:26 +01:00

31 lines
503 B
Go

package main
import (
"fmt"
"fluux.io/xmpp"
)
func main() {
component := xmpp.Component{Host: "mqtt.localhost", Secret: "mypass"}
component.Connect("localhost:8888")
for {
packet, err := component.ReadPacket()
if err != nil {
fmt.Println("read error", err)
return
}
switch p := packet.(type) {
case xmpp.IQ:
switch p.Payload.(type) {
case *xmpp.Query:
fmt.Println("Received query:", p.Type)
}
default:
fmt.Println("Packet unhandled packet:", packet)
}
}
}