mirror of
https://github.com/42wim/matterbridge.git
synced 2024-11-25 04:02:03 -08: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
|
return b.xc, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *Bxmpp) xmppKeepAlive() {
|
func (b *Bxmpp) xmppKeepAlive() chan bool {
|
||||||
|
done := make(chan bool)
|
||||||
go func() {
|
go func() {
|
||||||
ticker := time.NewTicker(90 * time.Second)
|
ticker := time.NewTicker(90 * time.Second)
|
||||||
|
defer ticker.Stop()
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
case <-ticker.C:
|
case <-ticker.C:
|
||||||
b.xc.Send(xmpp.Chat{})
|
b.xc.PingC2S("", "")
|
||||||
|
case <-done:
|
||||||
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
return done
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *Bxmpp) handleXmpp() error {
|
func (b *Bxmpp) handleXmpp() error {
|
||||||
|
done := b.xmppKeepAlive()
|
||||||
|
defer close(done)
|
||||||
for {
|
for {
|
||||||
m, err := b.xc.Recv()
|
m, err := b.xc.Recv()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user