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

@@ -31,9 +31,9 @@ func main() {
// Iterator to receive packets coming from our XMPP connection
for packet := range client.Recv() {
switch packet := packet.(type) {
case *xmpp.ClientMessage:
case *xmpp.Message:
fmt.Fprintf(os.Stdout, "Body = %s - from = %s\n", packet.Body, packet.From)
reply := xmpp.ClientMessage{PacketAttrs: xmpp.PacketAttrs{To: packet.From}, Body: packet.Body}
reply := xmpp.Message{PacketAttrs: xmpp.PacketAttrs{To: packet.From}, Body: packet.Body}
client.Send(reply.XMPPFormat())
default:
fmt.Fprintf(os.Stdout, "Ignoring packet: %T\n", packet)