From 7745e1f718c9cdce0055eb6dbd7c641ca32dd55b Mon Sep 17 00:00:00 2001 From: vduduh Date: Thu, 27 Feb 2020 23:18:50 +0300 Subject: [PATCH] Add Server-To-Client handler https://xmpp.org/extensions/xep-0199.html#s2c --- client.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/client.go b/client.go index bd40c38..48f19ae 100644 --- a/client.go +++ b/client.go @@ -309,6 +309,19 @@ func (c *Client) recv(state SMState, keepaliveQuit chan<- struct{}) { // Handle stream errors 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: c.router.route(c, val) close(keepaliveQuit)