5
0
mirror of https://github.com/cwinfo/matterbridge.git synced 2024-11-10 03:10:26 +00:00

Enable keepalive (xmpp)

This commit is contained in:
Wim 2016-11-26 15:02:39 +01:00
parent 4ef32103ca
commit 6c018ee6fe

View File

@ -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 {