Back to godoc.org
mellium.im/xmpp / roster

Package roster

v0.16.0
Latest Go to latest

The latest major version is .

Published: Mar 8, 2020 | License: BSD-2-Clause | Module: mellium.im/xmpp

Overview

Package roster implements contact list functionality.

Index

Constants

const (
	NS = "jabber:iq:roster"
)

Namespaces used by this package provided as a convenience.

func Handle

func Handle(h Handler) mux.Option

Handle returns an option that registers a Handler for roster pushes.

type Handler

type Handler struct {
	Push func(Item) error
}

Handler responds to roster pushes.

func (Handler) HandleIQ

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

HandleIQ responds to roster push IQs.

type IQ

type IQ struct {
	stanza.IQ

	Query struct {
		Ver  string `xml:"version,attr,omitempty"`
		Item []Item `xml:"item"`
	} `xml:"jabber:iq:roster query"`
}

IQ represents a user roster request or response. The zero value is a valid query for the roster.

func (IQ) MarshalXML

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

MarshalXML satisfies the xml.Marshaler interface.

func (IQ) TokenReader

func (iq IQ) TokenReader() xml.TokenReader

TokenReader returns a stream of XML tokens that match the IQ.

func (IQ) WriteXML

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

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

type Item

type Item struct {
	JID          jid.JID `xml:"jid,attr,omitempty"`
	Name         string  `xml:"name,attr,omitempty"`
	Subscription string  `xml:"subscription,attr,omitempty"`
	Group        string  `xml:"group,omitempty"`
}

Item represents a contact in the roster.

func (Item) MarshalXML

func (item Item) MarshalXML(e *xml.Encoder, _ xml.StartElement) error

MarshalXML satisfies the xml.Marshaler interface.

func (Item) TokenReader

func (item Item) TokenReader() xml.TokenReader

TokenReader satisfies the xmlstream.Marshaler interface.

func (Item) WriteXML

func (item Item) WriteXML(w xmlstream.TokenWriter) (n int, err error)

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

type Iter

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

Iter is an iterator over roster items.

func Fetch

func Fetch(ctx context.Context, s *xmpp.Session) *Iter

Fetch requests the roster and returns an iterator over all roster items (blocking until a response is received).

The iterator must be closed before anything else is done on the session or it will become invalid. Any errors encountered while creating the iter are deferred until the iter is used.

func FetchIQ

func FetchIQ(ctx context.Context, iq stanza.IQ, s *xmpp.Session) *Iter

FetchIQ is like Fetch but it allows you to customize the IQ. Changing the type of the provided IQ has no effect.

func (*Iter) Close

func (i *Iter) Close() error

Close indicates that we are finished with the given iterator and processing the stream may continue. Calling it multiple times has no effect.

func (*Iter) Err

func (i *Iter) Err() error

Err returns the last error encountered by the iterator (if any).

func (*Iter) Item

func (i *Iter) Item() Item

Item returns the last roster item parsed by the iterator.

func (*Iter) Next

func (i *Iter) Next() bool

Next returns true if there are more items to decode.

Package Files

Documentation was rendered with GOOS=linux and GOARCH=amd64.

Jump to identifier

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to identifier