v0.21.4 Latest Latest

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

Go to latest
Published: Jan 11, 2023 License: BSD-2-Clause Imports: 11 Imported by: 0



Package stream contains internal stream parsing and handling behavior.



This section is empty.


View Source
var (
	ErrUnknownStreamElement = errors.New("xmpp: unknown stream level element")
	ErrUnexpectedRestart    = errors.New("xmpp: unexpected stream restart")

Errors related to stream handling


func Close added in v0.21.4

func Close(w io.Writer, streamData *stream.Info) error

Close sends a stream end token.

func Expect

func Expect(ctx context.Context, in *stream.Info, d xml.TokenReader, recv, ws bool) error

Expect reads a token from d and expects that it will be a new stream start token. If not, an error is returned. It then handles feature negotiation for the new stream. If an XML header is discovered instead, it is skipped.

func Reader

func Reader(r xml.TokenReader) xml.TokenReader

Reader returns a token reader that handles stream level tokens on an already established stream.

func Send

func Send(rw io.ReadWriter, streamData *stream.Info, ws bool, version stream.Version, lang, to, from, id string) error

Send sends a new XML header followed by a stream start element on the given io.Writer. We don't use an xml.Encoder both because Go's standard library xml package really doesn't like the namespaced stream:stream attribute and because we can guarantee well-formedness of the XML with a print in this case and printing is much faster than encoding. Afterwards, clear the StreamRestartRequired bit and set the output stream information.


This section is empty.

Jump to

Keyboard shortcuts

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