Update example in README

This commit is contained in:
Mickael Remond 2019-06-22 11:29:47 +02:00
parent 555cbe12b4
commit 6ddfa781e5
No known key found for this signature in database
GPG key ID: E6F6045D79965AA3

View file

@ -44,7 +44,7 @@ func main() {
} }
router := xmpp.NewRouter() router := xmpp.NewRouter()
router.HandleFunc("message", HandleMessage) router.HandleFunc("message", handleMessage)
client, err := xmpp.NewClient(config, router) client, err := xmpp.NewClient(config, router)
if err != nil { if err != nil {
@ -57,7 +57,7 @@ func main() {
log.Fatal(cm.Run()) log.Fatal(cm.Run())
} }
func HandleMessage(s xmpp.Sender, p xmpp.Packet) { func handleMessage(s xmpp.Sender, p xmpp.Packet) {
msg, ok := p.(xmpp.Message) msg, ok := p.(xmpp.Message)
if !ok { if !ok {
_, _ = fmt.Fprintf(os.Stdout, "Ignoring packet: %T\n", p) _, _ = fmt.Fprintf(os.Stdout, "Ignoring packet: %T\n", p)
@ -65,7 +65,7 @@ func HandleMessage(s xmpp.Sender, p xmpp.Packet) {
} }
_, _ = fmt.Fprintf(os.Stdout, "Body = %s - from = %s\n", msg.Body, msg.From) _, _ = fmt.Fprintf(os.Stdout, "Body = %s - from = %s\n", msg.Body, msg.From)
reply := xmpp.Message{PacketAttrs: xmpp.PacketAttrs{To: msg.From}, Body: msg.Body} reply := xmpp.Message{Attrs: xmpp.Attrs{To: msg.From}, Body: msg.Body}
_ = s.Send(reply) _ = s.Send(reply)
} }
``` ```