forked from jshiffer/go-xmpp
Merge pull request #77 from ros-tel/master
Auto reply on server ping-request
This commit is contained in:
commit
62f9ce3246
6
xmpp.go
6
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(`<ping xmlns='urn:xmpp:ping'/>`)) {
|
||||
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
|
||||
}
|
||||
}
|
||||
|
@ -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, "<iq type='result' to='%s' id='%s'/>",
|
||||
xmlEscape(toServer), xmlEscape(id))
|
||||
return err
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user