mux

package
v0.19.0 Latest Latest
Warning

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

Go to latest
Published: May 2, 2021 License: BSD-2-Clause Imports: 7 Imported by: 7

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

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

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

HandleMessage calls f(msg, t).

type Option

type Option func(m *ServeMux)

Option configures a ServeMux.

func Handle

func Handle(n xml.Name, h xmpp.Handler) Option

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

func IQ(typ stanza.IQType, payload xml.Name, h IQHandler) Option

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

func IQFunc(typ stanza.IQType, payload xml.Name, h IQHandlerFunc) Option

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

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 New

func New(opt ...Option) *ServeMux

New allocates and returns a new ServeMux.

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

func (m *ServeMux) Handler(name xml.Name) (h xmpp.Handler, ok bool)

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

func (m *ServeMux) IQHandler(typ stanza.IQType, payload xml.Name) (h IQHandler, ok bool)

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).

Jump to

Keyboard shortcuts

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