xmpp: mellium.im/xmpp/internal/stream Index | Files

package stream

import "mellium.im/xmpp/internal/stream"

Package stream contains internal stream parsing and handling behavior.

Index

Package Files

reader.go stream.go version.go

Variables

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

Erorrs related to stream handling

var (
    DefaultVersion = Version{1, 0} // The default version to send.
    EmptyVersion   = Version{0, 9} // The value of a missing version attribute.
)

Common XMPP versions.

func Reader Uses

func Reader(r xml.TokenReader) xml.TokenReader

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

type Info Uses

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

Info contains metadata extracted from a stream start token.

func Expect Uses

func Expect(ctx context.Context, d xml.TokenReader, recv bool) (streamData Info, err 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 Send Uses

func Send(rw io.ReadWriter, s2s bool, version Version, lang string, location, origin, id string) (Info, 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.

type Version Uses

type Version struct {
    Major uint8
    Minor uint8
}

Version is a version of XMPP.

func MustParseVersion Uses

func MustParseVersion(s string) Version

MustParseVersion parses a version string and panics if an error is returned.

func ParseVersion Uses

func ParseVersion(s string) (Version, error)

ParseVersion parses a string of the form "Major.Minor" into a Version struct or returns an error.

func (Version) Less Uses

func (v Version) Less(b Version) bool

Less compares the major and minor version numbers, returning true if a is less than b.

func (Version) MarshalXMLAttr Uses

func (v Version) MarshalXMLAttr(name xml.Name) (xml.Attr, error)

MarshalXMLAttr satisfies the MarshalerAttr interface and marshals the version as an XML attribute using its string representation.

func (Version) String Uses

func (v Version) String() string

Prints a string representation of the XMPP version in the form "Major.Minor".

func (*Version) UnmarshalXMLAttr Uses

func (v *Version) UnmarshalXMLAttr(attr xml.Attr) error

UnmarshalXMLAttr satisfies the UnmarshalerAttr interface and unmarshals an XML attribute into a valid XMPP version (or returns an error).

Package stream imports 12 packages (graph) and is imported by 1 packages. Updated 2019-08-25. Refresh now. Tools for package owners.