diff options
author | bodqhrohro <bodqhrohro@gmail.com> | 2019-10-22 19:36:54 +0300 |
---|---|---|
committer | bodqhrohro <bodqhrohro@gmail.com> | 2019-10-22 19:36:54 +0300 |
commit | 9b4a09677a352d9938e4505bfc2d0c8d304567ac (patch) | |
tree | 1863f0d4c58f4019f86910f76c96f5823fd01dd4 /xmpp/handlers.go |
Hello world XMPP echo component
Diffstat (limited to 'xmpp/handlers.go')
-rw-r--r-- | xmpp/handlers.go | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/xmpp/handlers.go b/xmpp/handlers.go new file mode 100644 index 0000000..38bbe7a --- /dev/null +++ b/xmpp/handlers.go @@ -0,0 +1,21 @@ +package xmpp + +import ( + "fmt" + "os" + + "gosrc.io/xmpp" + "gosrc.io/xmpp/stanza" +) + +func HandleMessage(s xmpp.Sender, p stanza.Packet) { + msg, ok := p.(stanza.Message) + if !ok { + _, _ = fmt.Fprintf(os.Stdout, "Ignoring packet: %T\n", p) + return + } + + _, _ = fmt.Fprintf(os.Stdout, "Body = %s - from = %s\n", msg.Body, msg.From) + reply := stanza.Message{Attrs: stanza.Attrs{To: msg.From}, Body: msg.Body} + _ = s.Send(reply) +} |