diff options
author | Wim <wim@42.be> | 2016-11-26 15:02:39 +0100 |
---|---|---|
committer | Wim <wim@42.be> | 2016-11-26 15:04:06 +0100 |
commit | 6c018ee6fea5114cfeda9c3e1043c50b1139d3eb (patch) | |
tree | 03ba33b31ef5954a6f8dab3845ab9ccfcc1bcc0f /bridge/xmpp/xmpp.go | |
parent | 4ef32103cae4fe7e4908a8909f83efbf3c071651 (diff) | |
download | matterbridge-msglm-6c018ee6fea5114cfeda9c3e1043c50b1139d3eb.tar.gz matterbridge-msglm-6c018ee6fea5114cfeda9c3e1043c50b1139d3eb.tar.bz2 matterbridge-msglm-6c018ee6fea5114cfeda9c3e1043c50b1139d3eb.zip |
Enable keepalive (xmpp)
Diffstat (limited to 'bridge/xmpp/xmpp.go')
-rw-r--r-- | bridge/xmpp/xmpp.go | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/bridge/xmpp/xmpp.go b/bridge/xmpp/xmpp.go index f57fa515..9ec6b234 100644 --- a/bridge/xmpp/xmpp.go +++ b/bridge/xmpp/xmpp.go @@ -78,19 +78,26 @@ func (b *Bxmpp) createXMPP() (*xmpp.Client, error) { return b.xc, err } -func (b *Bxmpp) xmppKeepAlive() { +func (b *Bxmpp) xmppKeepAlive() chan bool { + done := make(chan bool) go func() { ticker := time.NewTicker(90 * time.Second) + defer ticker.Stop() for { select { case <-ticker.C: - b.xc.Send(xmpp.Chat{}) + b.xc.PingC2S("", "") + case <-done: + return } } }() + return done } func (b *Bxmpp) handleXmpp() error { + done := b.xmppKeepAlive() + defer close(done) for { m, err := b.xc.Recv() if err != nil { |