Documentation ¶
Overview ¶
Package receipts implements XEP-0184: Message Delivery Receipts.
Index ¶
- Constants
- Variables
- func Handle(h *Handler) mux.Option
- func Request(r xml.TokenReader) xml.TokenReader
- type Handler
- func (h *Handler) ForFeatures(node string, f func(info.Feature) error) error
- func (h *Handler) HandleMessage(msg stanza.Message, t xmlstream.TokenReadEncoder) error
- func (h *Handler) SendMessage(ctx context.Context, s *xmpp.Session, r xml.TokenReader) error
- func (h *Handler) SendMessageElement(ctx context.Context, s *xmpp.Session, payload xml.TokenReader, ...) error
- type Requested
Constants ¶
const ( // NS is the XML namespace used by message delivery receipts. // It is provided as a convenience. NS = "urn:xmpp:receipts" )
Variables ¶
var (
Feature = info.Feature{Var: NS}
)
A list of service discovery features that are supported by this package.
Functions ¶
func Request ¶ added in v0.18.0
func Request(r xml.TokenReader) xml.TokenReader
Request is an xmlstream.Transformer that inserts a request for a read receipt into any message read through r that is not itself a receipt. It is provided to allow easily requesting read receipts asynchronously. To send a message and block waiting on a read receipt, see the methods on Handler.
Types ¶
type Handler ¶
type Handler struct { Unhandled func(string) // contains filtered or unexported fields }
Handler listens for incoming message receipts and matches them to outgoing messages sent with SendMessage or SendMessageElement. If Unhandled is set it is called for every receipt that cannot be matched to a message sent through the handler.
func (*Handler) ForFeatures ¶ added in v0.20.0
ForFeatures implements info.FeatureIter.
func (*Handler) HandleMessage ¶
HandleMessage implements mux.MessageHandler and responds to requests and responses for message delivery receipts.
func (*Handler) SendMessage ¶
SendMessage transmits the first element read from the provided token reader over the session if the element is a message stanza, otherwise it returns an error. SendMessage adds a request for a message receipt and an ID if one does not already exist.
If the context is closed before the message delivery receipt is received, SendMessage immediately returns the context error. Any response received at a later time will no be associated with the original request, but can still be handled by the Handler. If the returned error is nil, receipt of the message was successfully acknowledged.
SendMessage is safe for concurrent use by multiple goroutines.
func (*Handler) SendMessageElement ¶
func (h *Handler) SendMessageElement(ctx context.Context, s *xmpp.Session, payload xml.TokenReader, msg stanza.Message) error
SendMessageElement is like SendMessage except that it wraps the payload in the message element derived from msg. For more information, see SendMessage.
SendMessageElement is safe for concurrent use by multiple goroutines.
type Requested ¶ added in v0.18.0
type Requested bool
Requested is a type that can be added to messages to enable or disable requesting a read receipt.
This type is used to manually include a request in a message struct. To send a message and wait for the receipt see the methods on Handler.
func (Requested) MarshalXML ¶ added in v0.18.0
MarshalXML implements xml.Marshaler.
func (Requested) TokenReader ¶ added in v0.18.0
func (r Requested) TokenReader() xml.TokenReader
TokenReader implements xmlstream.Marshaler.
func (*Requested) UnmarshalXML ¶ added in v0.18.0
UnmarshalXML implements xml.Unmarshaler.