aboutsummaryrefslogtreecommitdiff
path: root/xmpp/component.go
diff options
context:
space:
mode:
Diffstat (limited to 'xmpp/component.go')
-rw-r--r--xmpp/component.go19
1 files changed, 7 insertions, 12 deletions
diff --git a/xmpp/component.go b/xmpp/component.go
index 57d9c7b..bc81126 100644
--- a/xmpp/component.go
+++ b/xmpp/component.go
@@ -13,11 +13,9 @@ import (
"gosrc.io/xmpp"
)
-const pollingInterval time.Duration = 1e7
-
var tgConf config.TelegramConfig
var sessions map[string]*telegram.Client
-var db persistence.SessionsYamlDB
+var db *persistence.SessionsYamlDB
// NewComponent starts a new component and wraps it in
// a stream manager that you should start yourself
@@ -53,9 +51,9 @@ func NewComponent(conf config.XMPPConfig, tc config.TelegramConfig) (*xmpp.Strea
return nil, nil, err
}
- sm := xmpp.NewStreamManager(component, nil)
-
- go heartbeat(component)
+ sm := xmpp.NewStreamManager(component, func(s xmpp.Sender) {
+ go heartbeat(component)
+ })
return sm, component, nil
}
@@ -65,12 +63,9 @@ func heartbeat(component *xmpp.Component) {
probeType := gateway.SPType("probe")
for jid := range sessions {
- for {
- err = gateway.SendPresence(component, jid, probeType)
- if err == nil {
- break
- }
- time.Sleep(pollingInterval)
+ err = gateway.SendPresence(component, jid, probeType)
+ if err != nil {
+ log.Error(err)
}
}