Stop receive loop when XMPP connection is closed.

change-name
Robert Jacob 5 years ago
parent 0e1dc803ac
commit 05df498087
  1. 7
      xmpp/xmpp.go

@ -3,6 +3,7 @@ package xmpp
import (
"crypto/tls"
"fmt"
"io"
"log"
"net"
"strings"
@ -60,7 +61,11 @@ func AddXMPPListener(storage *spaceapi.Storage, jid, password, target, handle st
go func() {
for {
chat, err := client.Recv()
if err != nil {
switch {
case err == io.EOF:
log.Println("Lost XMPP connection.")
return
case err != nil:
log.Printf("Error receiving XMPP message: %s", err)
continue
}

Loading…
Cancel
Save