mirror of
https://github.com/FluuxIO/go-xmpp.git
synced 2024-11-23 19:12:00 -08:00
Close keepalive when recv() ends in client.go
This commit is contained in:
parent
64e54134df
commit
6e84084bb3
@ -379,11 +379,13 @@ func (c *Client) sendWithWriter(writer io.Writer, packet []byte) error {
|
|||||||
|
|
||||||
// Loop: Receive data from server
|
// Loop: Receive data from server
|
||||||
func (c *Client) recv(keepaliveQuit chan<- struct{}) {
|
func (c *Client) recv(keepaliveQuit chan<- struct{}) {
|
||||||
|
defer func() {
|
||||||
|
close(keepaliveQuit)
|
||||||
|
}()
|
||||||
for {
|
for {
|
||||||
val, err := stanza.NextPacket(c.transport.GetDecoder())
|
val, err := stanza.NextPacket(c.transport.GetDecoder())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.ErrorHandler(err)
|
c.ErrorHandler(err)
|
||||||
close(keepaliveQuit)
|
|
||||||
c.disconnected(c.Session.SMState)
|
c.disconnected(c.Session.SMState)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -392,7 +394,6 @@ func (c *Client) recv(keepaliveQuit chan<- struct{}) {
|
|||||||
switch packet := val.(type) {
|
switch packet := val.(type) {
|
||||||
case stanza.StreamError:
|
case stanza.StreamError:
|
||||||
c.router.route(c, val)
|
c.router.route(c, val)
|
||||||
close(keepaliveQuit)
|
|
||||||
c.streamError(packet.Error.Local, packet.Text)
|
c.streamError(packet.Error.Local, packet.Text)
|
||||||
c.ErrorHandler(errors.New("stream error: " + packet.Error.Local))
|
c.ErrorHandler(errors.New("stream error: " + packet.Error.Local))
|
||||||
// We don't return here, because we want to wait for the stream close tag from the server, or timeout.
|
// We don't return here, because we want to wait for the stream close tag from the server, or timeout.
|
||||||
|
Loading…
Reference in New Issue
Block a user