Version: v0.21.3 Latest Latest

This package is not in the latest version of its module.

Go to latest
Published: Aug 18, 2022 License: BSD-2-Clause Imports: 9 Imported by: 0



Package ping implements XEP-0199: XMPP Ping.



View Source
const NS = `urn:xmpp:ping`

NS is the XML namespace used by XMPP pings. It is provided as a convenience.


View Source
var (
	Feature = info.Feature{Var: NS}

A list of service discovery features that are supported by this package.


func Handle added in v0.15.0

func Handle() mux.Option

Handle returns an option that registers a Handler for ping requests.

func Send added in v0.15.0

func Send(ctx context.Context, s *xmpp.Session, to jid.JID) error

Send sends a ping to the provided JID and blocks until a response is received. Pings sent to other clients should use the full JID, otherwise they will be handled by the server.

If the remote JID reports that the ping service is unavailable, no error is returned because we were able to receive the error response (the remote resource exists and could be pinged, it just doesn't support this particular protocol for doing so).


type Handler added in v0.15.0

type Handler struct{}

Handler responds to ping requests.

func (Handler) ForFeatures added in v0.20.0

func (h Handler) ForFeatures(node string, f func(info.Feature) error) error

ForFeatures implements info.FeatureIter.

func (Handler) HandleIQ added in v0.15.0

func (h Handler) HandleIQ(iq stanza.IQ, t xmlstream.TokenReadEncoder, start *xml.StartElement) error

HandleIQ implements mux.IQHandler.

type IQ added in v0.3.0

type IQ struct {

	Ping struct{} `xml:"urn:xmpp:ping ping"`

IQ is encoded as a ping request.

func (IQ) MarshalXML added in v0.19.0

func (iq IQ) MarshalXML(e *xml.Encoder, _ xml.StartElement) error

MarshalXML implements xml.Marshaler.

func (IQ) TokenReader added in v0.14.0

func (iq IQ) TokenReader() xml.TokenReader

TokenReader satisfies the xmlstream.Marshaler interface.

func (IQ) WriteXML added in v0.14.0

func (iq IQ) WriteXML(w xmlstream.TokenWriter) (int, error)

WriteXML satisfies the xmlstream.WriterTo interface. It is like MarshalXML except it writes tokens to w.

Source Files

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL