Refactor parsing / improve typing

This commit is contained in:
Mickael Remond
2018-01-13 18:50:17 +01:00
parent 01063ec284
commit 10219ec1e6
15 changed files with 198 additions and 82 deletions

View File

@@ -11,11 +11,18 @@ func main() {
component.Connect("localhost:8888")
for {
_, packet, err := component.ReadPacket()
packet, err := component.ReadPacket()
if err != nil {
fmt.Println("read error", err)
return
}
fmt.Println("Packet received: ", packet)
switch p := packet.(type) {
case xmpp.IQ:
fmt.Println("IQ received: ", p)
fmt.Println("IQ type:", p.Type)
default:
fmt.Println("Packet unhandled packet:", packet)
}
}
}