diff --git a/xmpp.go b/xmpp.go index a792e5a..c12dd52 100644 --- a/xmpp.go +++ b/xmpp.go @@ -600,6 +600,12 @@ func (c *Client) Recv() (stanza interface{}, err error) { case *clientPresence: return Presence{v.From, v.To, v.Type, v.Show, v.Status}, nil case *clientIQ: + if bytes.Equal(v.Query, []byte(``)) { + err := c.SendResultPing(v.ID, v.From) + if err != nil { + return Chat{}, err + } + } return IQ{ID: v.ID, From: v.From, To: v.To, Type: v.Type, Query: v.Query}, nil } } diff --git a/xmpp_ping.go b/xmpp_ping.go index 26d056e..39269d8 100644 --- a/xmpp_ping.go +++ b/xmpp_ping.go @@ -25,3 +25,9 @@ func (c *Client) PingS2S(fromServer, toServer string) error { xmlEscape(fromServer), xmlEscape(toServer)) return err } + +func (c *Client) SendResultPing(id, toServer string) error { + _, err := fmt.Fprintf(c.conn, "", + xmlEscape(toServer), xmlEscape(id)) + return err +}