carbons

package
Version: v0.21.3 Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2022 License: BSD-2-Clause Imports: 10 Imported by: 0

Documentation

Overview

Package carbons implements carbon copying messages to all interested clients.

Index

Constants

View Source
const (
	NS      = `urn:xmpp:carbons:2`
	NSRules = `urn:xmpp:carbons:rules:0`
)

Namespaces used by this package, provided as a convenience.

Variables

View Source
var (
	Feature = info.Feature{Var: NS}
)

A list of service discovery features that are supported by this package.

Functions

func Disable

func Disable(ctx context.Context, s *xmpp.Session) error

Disable instructs the server to stop carbon copying messages on the given session.

func DisableIQ

func DisableIQ(ctx context.Context, s *xmpp.Session, iq stanza.IQ) error

DisableIQ is like Disable but it allows you to customize the IQ stanza being sent. Changing the type of the IQ has no effect.

func Enable

func Enable(ctx context.Context, s *xmpp.Session) error

Enable instructs the server to start carbon copying messages on the given session.

func EnableIQ

func EnableIQ(ctx context.Context, s *xmpp.Session, iq stanza.IQ) error

EnableIQ is like Enable but it allows you to customize the IQ stanza being sent. Changing the type of the IQ has no effect.

func Handle

func Handle(h Handler) mux.Option

Handle returns an option that registers a handler for carbon copied messages on the multiplexer.

func Private added in v0.21.0

func Private(r xml.TokenReader) xml.TokenReader

Private is an xmlstream.Transformer that excludes all top level <message/> elements from being forwarded to other Carbons-enabled resources, by adding a <private/> element and a <no-copy/> hint.

func Unwrap added in v0.21.0

Unwrap unwraps a carbon copied message, unmarshals the forwarding delay into the provided delay, and returns a start element set to either sent or received. If the provided delay is nil, unmarshaling is skipped.

func WrapReceived added in v0.21.0

func WrapReceived(delay delay.Delay, r xml.TokenReader) xml.TokenReader

WrapReceived wraps the provided token reader (which should be a message stanza, but this is not enforced) in a received element.

func WrapSent added in v0.21.0

func WrapSent(delay delay.Delay, r xml.TokenReader) xml.TokenReader

WrapSent wraps the provided token reader (which should be a message stanza, but this is not enforced) in a sent element.

Types

type Handler

type Handler struct {
	F func(m stanza.Message, sent bool, inner xml.TokenReader) error
}

Handler can be used to handle incoming carbon copied messages.

func (Handler) ForFeatures

func (h Handler) ForFeatures(node string, f func(info.Feature) error) error

ForFeatures implements info.FeatureIter.

func (Handler) HandleMessage

func (h Handler) HandleMessage(p stanza.Message, r xmlstream.TokenReadEncoder) error

HandleMessage satisfies mux.MessageHandler. it is used by the multiplexer and normally does not need to be called by the user.

Jump to

Keyboard shortcuts

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