aboutsummaryrefslogtreecommitdiff
path: root/xmpp/component.go
diff options
context:
space:
mode:
authorbodqhrohro <bodqhrohro@gmail.com>2019-10-22 19:36:54 +0300
committerbodqhrohro <bodqhrohro@gmail.com>2019-10-22 19:36:54 +0300
commit9b4a09677a352d9938e4505bfc2d0c8d304567ac (patch)
tree1863f0d4c58f4019f86910f76c96f5823fd01dd4 /xmpp/component.go
Hello world XMPP echo component
Diffstat (limited to 'xmpp/component.go')
-rw-r--r--xmpp/component.go30
1 files changed, 30 insertions, 0 deletions
diff --git a/xmpp/component.go b/xmpp/component.go
new file mode 100644
index 0000000..e484e99
--- /dev/null
+++ b/xmpp/component.go
@@ -0,0 +1,30 @@
+package xmpp
+
+import (
+ "log"
+
+ "dev.narayana.im/narayana/telegabber/config"
+
+ "gosrc.io/xmpp"
+)
+
+func NewComponent(conf config.XmppConfig) *xmpp.StreamManager {
+ options := xmpp.ComponentOptions{
+ Address: conf.Host + ":" + conf.Port,
+ Domain: conf.Jid,
+ Secret: conf.Password,
+ Name: "telegabber",
+ }
+
+ router := xmpp.NewRouter()
+ router.HandleFunc("message", HandleMessage)
+
+ component, err := xmpp.NewComponent(options, router)
+ if err != nil {
+ log.Fatalf("%+v", err)
+ }
+
+ cm := xmpp.NewStreamManager(component, nil)
+
+ return cm
+}