mirror of
https://github.com/FluuxIO/go-xmpp.git
synced 2024-11-21 18:12:00 -08:00
Move code to router
This commit is contained in:
parent
7745e1f718
commit
ee38abcca9
13
client.go
13
client.go
@ -309,19 +309,6 @@ func (c *Client) recv(state SMState, keepaliveQuit chan<- struct{}) {
|
|||||||
|
|
||||||
// Handle stream errors
|
// Handle stream errors
|
||||||
switch packet := val.(type) {
|
switch packet := val.(type) {
|
||||||
case *stanza.IQ:
|
|
||||||
if val.(*stanza.IQ).Any != nil && val.(*stanza.IQ).Any.XMLName.Local == "ping" {
|
|
||||||
err = c.Send(&stanza.IQ{Attrs: stanza.Attrs{
|
|
||||||
Id: val.(*stanza.IQ).Id,
|
|
||||||
Type: stanza.IQTypeResult,
|
|
||||||
From: val.(*stanza.IQ).To,
|
|
||||||
To: val.(*stanza.IQ).From,
|
|
||||||
}})
|
|
||||||
if err != nil {
|
|
||||||
c.ErrorHandler(err)
|
|
||||||
}
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
case stanza.StreamError:
|
case stanza.StreamError:
|
||||||
c.router.route(c, val)
|
c.router.route(c, val)
|
||||||
close(keepaliveQuit)
|
close(keepaliveQuit)
|
||||||
|
@ -55,6 +55,15 @@ func (r *Router) route(s Sender, p stanza.Packet) {
|
|||||||
close(route.result)
|
close(route.result)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if iq.Any != nil && iq.Any.XMLName.Local == "ping" {
|
||||||
|
_ = s.Send(&stanza.IQ{Attrs: stanza.Attrs{
|
||||||
|
Id: iq.Id,
|
||||||
|
Type: stanza.IQTypeResult,
|
||||||
|
From: iq.To,
|
||||||
|
To: iq.From,
|
||||||
|
}})
|
||||||
|
return
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var match RouteMatch
|
var match RouteMatch
|
||||||
|
Loading…
Reference in New Issue
Block a user