xmpp

package
v0.0.0-...-875004a Latest Latest
Warning

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

Go to latest
Published: Aug 2, 2021 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NSStream = "http://etherx.jabber.org/streams"
	NSTLS    = "urn:ietf:params:xml:ns:xmpp-tls"
	NSClient = "jabber:client"
	NSServer = "jabber:server"
	NSSASL   = "urn:ietf:params:xml:ns:xmpp-sasl"
)

Variables

This section is empty.

Functions

func NewRoute

func NewRoute() *route

NewRoute returns a blank route that matches nothing and has no Handler.

Types

type AllMatcher

type AllMatcher struct{}

AllMatcher is a Matcher that matches any Element.

func (AllMatcher) Match

func (m AllMatcher) Match(e Element) bool

type Decoder

type Decoder struct {
	Header string
	// contains filtered or unexported fields
}

A Decoder represents an XMPP parser reading a particular input stream. The parser uses xml.Decoder under the hood.

func NewDecoder

func NewDecoder(r io.Reader) *Decoder

NewDecoder creates a new Decoder reading from r.

func (*Decoder) NextElement

func (d *Decoder) NextElement() (Element, error)

NextElement returns the next Element in the stream.

type Element

type Element interface {
	Name() xml.Name // Name() returns the xml.Name of the element.
	XML() string    // XML() returns a string representation of the element's XML.
}

An Element represents a single XML Element inside of an XMPP stream. This can be an XMPP stanza, stream management elements, SASL elements, etc.

type GenericElement

type GenericElement struct {
	// contains filtered or unexported fields
}

A GenericElement is used to represent any generic XMPP Element by storing their raw XML as a string as well as their resolved xml.Name.

func NewGenericElement

func NewGenericElement(name xml.Name, xml string) *GenericElement

NewGenericElement creates a GenericElement given a name and the raw XML for an XMPP Element.

func (GenericElement) Name

func (e GenericElement) Name() xml.Name

func (GenericElement) XML

func (e GenericElement) XML() string

type Handler

type Handler interface {
	HandleElement(e Element) error
}

Handler is an interface used to handle a route

type HandlerFunc

type HandlerFunc func(e Element) error

The HandlerFunc type is an adapter to allow the use of ordinary functions as Handlers. If f is a function with the appropriate signature, HandlerFunc(f) is a Handler that calls f.

func (HandlerFunc) HandleElement

func (f HandlerFunc) HandleElement(e Element) error

HandleElement calls f(s, p)

type Matcher

type Matcher interface {
	Match(Element) bool
}

Matcher.Match returns true if the Element meets the conditions of the Matcher

type NameMatcher

type NameMatcher xml.Name

NameMatcher is a Matcher that checks to see if e.Name is equal to itself.

func (NameMatcher) Match

func (m NameMatcher) Match(e Element) bool

type Route

type Route interface {
	Match(Element) bool
	Handler() Handler
}

A Route is used to check an xmpp.Element and process it via a custom Handler

type Router

type Router struct {
	// contains filtered or unexported fields
}

A Router contains Routes which are used to process XMPP Elements via different handlers.

func NewRouter

func NewRouter() *Router

NewRouter returns an empty Router

func (*Router) AddRoute

func (r *Router) AddRoute(route Route)

AddRoute adds a Route to r.

func (*Router) AddRoutes

func (r *Router) AddRoutes(routes ...Route)

AddRoutes adds a variable number of Routes to r.

func (*Router) Route

func (r *Router) Route(e Element) error

Route takes an element and executes its relevant Handler if a match is found.

type SpaceMatcher

type SpaceMatcher string

SpaceMatcher is a Matcher that checks to see if e.Name.Space is equal to itself.

func (SpaceMatcher) Match

func (m SpaceMatcher) Match(e Element) bool

type Stream

type Stream struct {
	From    string
	To      string
	ID      string
	Version string
	// contains filtered or unexported fields
}

Stream is a custom Element that represents the start of a stream. Unlike normal XMPP Elements, a Stream's XML() method should not return the closing </stream> tag. Normal XMPP Elements have a depth=1 whereas the start of a stream is depth=0

func NewStream

func NewStream(rawSE xml.StartElement) *Stream

NewStream returns a new Stream that implements xmpp.Element

func (Stream) Name

func (s Stream) Name() xml.Name

func (Stream) XML

func (s Stream) XML() string

type StreamEnd

type StreamEnd struct{}

Empty Struct to represent the end of a stream.

func (StreamEnd) Name

func (s StreamEnd) Name() xml.Name

func (StreamEnd) XML

func (s StreamEnd) XML() string

Jump to

Keyboard shortcuts

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