Documentation ¶
Overview ¶
Package mux contains a simple XMPP multiplexer.
Aside from implementing its own muxer, this package contains handler interfaces designed to be standard across multiplexers. This lets you write, for example, a muxer that matches elements based on xpath expressions and take advantage of existing handlers.
Index ¶
- type IQHandler
- type IQHandlerFunc
- type MessageHandler
- type MessageHandlerFunc
- type Option
- func Handle(n xml.Name, h xmpp.Handler) Option
- func HandleFunc(n xml.Name, h xmpp.HandlerFunc) Option
- func IQ(typ stanza.IQType, payload xml.Name, h IQHandler) Option
- func IQFunc(typ stanza.IQType, payload xml.Name, h IQHandlerFunc) Option
- func Message(typ stanza.MessageType, payload xml.Name, h MessageHandler) Option
- func MessageFunc(typ stanza.MessageType, payload xml.Name, h MessageHandlerFunc) Option
- func Presence(typ stanza.PresenceType, payload xml.Name, h PresenceHandler) Option
- func PresenceFunc(typ stanza.PresenceType, payload xml.Name, h PresenceHandlerFunc) Option
- type PresenceHandler
- type PresenceHandlerFunc
- type ServeMux
- func (m *ServeMux) HandleXMPP(t xmlstream.TokenReadEncoder, start *xml.StartElement) error
- func (m *ServeMux) Handler(name xml.Name) (h xmpp.Handler, ok bool)
- func (m *ServeMux) IQHandler(typ stanza.IQType, payload xml.Name) (h IQHandler, ok bool)
- func (m *ServeMux) MessageHandler(typ stanza.MessageType, payload xml.Name) (h MessageHandler, ok bool)
- func (m *ServeMux) PresenceHandler(typ stanza.PresenceType, payload xml.Name) (h PresenceHandler, ok bool)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type IQHandler ¶ added in v0.15.0
type IQHandler interface {
HandleIQ(stanza.IQ, xmlstream.TokenReadEncoder, *xml.StartElement) error
}
IQHandler responds to IQ stanzas.
type IQHandlerFunc ¶ added in v0.15.0
type IQHandlerFunc func(stanza.IQ, xmlstream.TokenReadEncoder, *xml.StartElement) error
The IQHandlerFunc type is an adapter to allow the use of ordinary functions as IQ handlers. If f is a function with the appropriate signature, IQHandlerFunc(f) is an IQHandler that calls f.
func (IQHandlerFunc) HandleIQ ¶ added in v0.15.0
func (f IQHandlerFunc) HandleIQ(iq stanza.IQ, t xmlstream.TokenReadEncoder, start *xml.StartElement) error
HandleIQ calls f(iq, t, start).
type MessageHandler ¶ added in v0.15.0
type MessageHandler interface {
HandleMessage(stanza.Message, xmlstream.TokenReadEncoder) error
}
MessageHandler responds to message stanzas.
type MessageHandlerFunc ¶ added in v0.15.0
type MessageHandlerFunc func(stanza.Message, xmlstream.TokenReadEncoder) error
The MessageHandlerFunc type is an adapter to allow the use of ordinary functions as message handlers. If f is a function with the appropriate signature, MessageHandlerFunc(f) is a MessageHandler that calls f.
func (MessageHandlerFunc) HandleMessage ¶ added in v0.15.0
func (f MessageHandlerFunc) HandleMessage(msg stanza.Message, t xmlstream.TokenReadEncoder) error
HandleMessage calls f(msg, t).
type Option ¶
type Option func(m *ServeMux)
Option configures a ServeMux.
func Handle ¶
Handle returns an option that matches on the provided XML name. If a handler already exists for n when the option is applied, the option panics.
func HandleFunc ¶ added in v0.9.0
func HandleFunc(n xml.Name, h xmpp.HandlerFunc) Option
HandleFunc returns an option that matches on the provided XML name.
func IQ ¶
IQ returns an option that matches IQ stanzas based on their type and the name of the payload.
func IQFunc ¶ added in v0.10.0
IQFunc returns an option that matches IQ stanzas. For more information see IQ.
func Message ¶
func Message(typ stanza.MessageType, payload xml.Name, h MessageHandler) Option
Message returns an option that matches message stanzas by type.
func MessageFunc ¶ added in v0.10.0
func MessageFunc(typ stanza.MessageType, payload xml.Name, h MessageHandlerFunc) Option
MessageFunc returns an option that matches message stanzas. For more information see Message.
func Presence ¶
func Presence(typ stanza.PresenceType, payload xml.Name, h PresenceHandler) Option
Presence returns an option that matches presence stanzas by type.
func PresenceFunc ¶ added in v0.10.0
func PresenceFunc(typ stanza.PresenceType, payload xml.Name, h PresenceHandlerFunc) Option
PresenceFunc returns an option that matches on presence stanzas. For more information see Presence.
type PresenceHandler ¶ added in v0.15.0
type PresenceHandler interface {
HandlePresence(stanza.Presence, xmlstream.TokenReadEncoder) error
}
PresenceHandler responds to message stanzas.
type PresenceHandlerFunc ¶ added in v0.15.0
type PresenceHandlerFunc func(stanza.Presence, xmlstream.TokenReadEncoder) error
The PresenceHandlerFunc type is an adapter to allow the use of ordinary functions as presence handlers. If f is a function with the appropriate signature, PresenceHandlerFunc(f) is a PresenceHandler that calls f.
func (PresenceHandlerFunc) HandlePresence ¶ added in v0.15.0
func (f PresenceHandlerFunc) HandlePresence(p stanza.Presence, t xmlstream.TokenReadEncoder) error
HandlePresence calls f(p, t).
type ServeMux ¶
type ServeMux struct {
// contains filtered or unexported fields
}
ServeMux is an XMPP stream multiplexer. It matches the start element token of each top level stream element against a list of registered patterns and calls the handler for the pattern that most closely matches the token.
Patterns are XML names. If either the namespace or the localname is left off, any namespace or localname will be matched. Full XML names take precedence, followed by wildcard localnames, followed by wildcard namespaces.
func (*ServeMux) HandleXMPP ¶
func (m *ServeMux) HandleXMPP(t xmlstream.TokenReadEncoder, start *xml.StartElement) error
HandleXMPP dispatches the request to the handler that most closely matches.
func (*ServeMux) Handler ¶
Handler returns the handler to use for a top level element with the provided XML name. If no exact match or wildcard handler exists, a default handler is returned (h is always non-nil) and ok will be false.
func (*ServeMux) IQHandler ¶ added in v0.15.0
IQHandler returns the handler to use for an IQ payload with the given type and payload name. If no handler exists, a default handler is returned (h is always non-nil).
func (*ServeMux) MessageHandler ¶ added in v0.15.0
func (m *ServeMux) MessageHandler(typ stanza.MessageType, payload xml.Name) (h MessageHandler, ok bool)
MessageHandler returns the handler to use for a message with the given type and payload. If no handler exists, a default handler is returned (h is always non-nil).
func (*ServeMux) PresenceHandler ¶ added in v0.15.0
func (m *ServeMux) PresenceHandler(typ stanza.PresenceType, payload xml.Name) (h PresenceHandler, ok bool)
PresenceHandler returns the handler to use for a presence payload with the given type. If no handler exists, a default handler is returned (h is always non-nil).