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:
parent
4ef32103ca
commit
6c018ee6fe
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user