2018-01-11 13:15:54 -08:00
|
|
|
package main
|
|
|
|
|
2018-01-12 10:08:47 -08:00
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
|
|
|
|
"fluux.io/xmpp"
|
|
|
|
)
|
2018-01-11 13:15:54 -08:00
|
|
|
|
|
|
|
func main() {
|
2018-01-12 09:14:41 -08:00
|
|
|
component := xmpp.Component{Host: "mqtt.localhost", Secret: "mypass"}
|
|
|
|
component.Connect("localhost:8888")
|
2018-01-12 10:08:47 -08:00
|
|
|
|
|
|
|
for {
|
2018-01-13 09:50:17 -08:00
|
|
|
packet, err := component.ReadPacket()
|
2018-01-12 10:08:47 -08:00
|
|
|
if err != nil {
|
2018-01-13 08:46:10 -08:00
|
|
|
fmt.Println("read error", err)
|
2018-01-12 10:08:47 -08:00
|
|
|
return
|
|
|
|
}
|
2018-01-13 09:50:17 -08:00
|
|
|
|
|
|
|
switch p := packet.(type) {
|
|
|
|
case xmpp.IQ:
|
2018-01-13 10:14:26 -08:00
|
|
|
switch p.Payload.(type) {
|
|
|
|
case *xmpp.Query:
|
|
|
|
fmt.Println("Received query:", p.Type)
|
|
|
|
}
|
2018-01-13 09:50:17 -08:00
|
|
|
default:
|
|
|
|
fmt.Println("Packet unhandled packet:", packet)
|
|
|
|
}
|
2018-01-12 10:08:47 -08:00
|
|
|
}
|
2018-01-11 13:15:54 -08:00
|
|
|
}
|