xmpp

package
v0.0.0-...-aeec266 Latest Latest
Warning

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

Go to latest
Published: Jan 5, 2021 License: BSD-3-Clause Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// MessageName represents "message" stanza name.
	MessageName = "message"

	// PresenceName represents "presence" stanza name.
	PresenceName = "presence"

	// IQName represents "iq" stanza name.
	IQName = "iq"
)
View Source
const (
	// GetType represents a 'get' IQ type.
	GetType = "get"

	// SetType represents a 'set' IQ type.
	SetType = "set"

	// ResultType represents a 'result' IQ type.
	ResultType = "result"
)
View Source
const (
	// NormalType represents a 'normal' message type.
	NormalType = "normal"

	// HeadlineType represents a 'headline' message type.
	HeadlineType = "headline"

	// ChatType represents a 'chat' message type.
	ChatType = "chat"

	// GroupChatType represents a 'groupchat' message type.
	GroupChatType = "groupchat"
)
View Source
const (
	// DefaultMode treats incoming elements as provided from raw byte reader.
	DefaultMode = ParsingMode(iota)

	// SocketStream treats incoming elements as provided from a socket transport.
	SocketStream
)
View Source
const (
	// AvailableType represents an 'available' Presence type.
	AvailableType = ""

	// UnavailableType represents an 'unavailable' Presence type.
	UnavailableType = "unavailable"

	// SubscribeType represents an 'subscribe' Presence type.
	SubscribeType = "subscribe"

	// UnsubscribeType represents an 'unsubscribe' Presence type.
	UnsubscribeType = "unsubscribe"

	// SubscribedType represents an 'subscribed' Presence type.
	SubscribedType = "subscribed"

	// UnsubscribedType represents an 'unsubscribed' Presence type.
	UnsubscribedType = "unsubscribed"

	// ProbeType represents an 'probe' Presence type.
	ProbeType = "probe"
)
View Source
const ErrorType = "error"

ErrorType represents an 'error' stanza type.

Variables

View Source
var (
	// ErrBadRequest is returned by the stream when the sender
	// has sent XML that is malformed or that cannot be processed.
	ErrBadRequest = newStanzaError(400, modifyErrorType, badRequestErrorReason)

	// ErrConflict is returned by the stream when access cannot be
	// granted because an existing resource or session exists with
	// the same name or address.
	ErrConflict = newStanzaError(409, cancelErrorType, conflictErrorReason)

	// ErrFeatureNotImplemented is returned by the stream when the feature
	// requested is not implemented by the server and therefore cannot be processed.
	ErrFeatureNotImplemented = newStanzaError(501, cancelErrorType, featureNotImplementedErrorReason)

	// ErrForbidden is returned by the stream when the requesting
	// entity does not process the required permissions to perform the action.
	ErrForbidden = newStanzaError(403, authErrorType, forbiddenErrorReason)

	// ErrGone is returned by the stream when the recipient or server
	// can no longer be contacted at this address.
	ErrGone = newStanzaError(302, modifyErrorType, goneErrorReason)

	// ErrInternalServerError is returned by the stream when the server
	// could not process the stanza because of a misconfiguration
	// or an otherwise-undefined internal server error.
	ErrInternalServerError = newStanzaError(500, waitErrorType, internalServerErrorErrorReason)

	// ErrItemNotFound is returned by the stream when the addressed
	// JID or item requested cannot be found.
	ErrItemNotFound = newStanzaError(404, cancelErrorType, itemNotFoundErrorReason)

	// ErrJidMalformed is returned by the stream when the sending entity
	// has provided or communicated an XMPP address or aspect thereof that
	// does not adhere to the syntax defined in https://xmpp.org/rfcs/rfc3920.html#addressing.
	ErrJidMalformed = newStanzaError(400, modifyErrorType, jidMalformedErrorReason)

	// ErrNotAcceptable is returned by the stream when the server
	// understands the request but is refusing to process it because
	// it does not meet the defined criteria.
	ErrNotAcceptable = newStanzaError(406, modifyErrorType, notAcceptableErrorReason)

	// ErrNotAllowed is returned by the stream when the recipient
	// or server does not allow any entity to perform the action.
	ErrNotAllowed = newStanzaError(405, cancelErrorType, notAllowedErrorReason)

	// ErrNotAuthorized is returned by the stream when the sender
	// must provide proper credentials before being allowed to perform the action,
	// or has provided improper credentials.
	ErrNotAuthorized = newStanzaError(405, authErrorType, notAuthroizedErrorReason)

	// ErrPaymentRequired is returned by the stream when the requesting entity
	// is not authorized to access the requested service because payment is required.
	ErrPaymentRequired = newStanzaError(402, authErrorType, paymentRequiredErrorReason)

	// ErrRecipientUnavailable is returned by the stream when the intended
	// recipient is temporarily unavailable.
	ErrRecipientUnavailable = newStanzaError(404, waitErrorType, recipientUnavailableErrorReason)

	// ErrRedirect is returned by the stream when the recipient or server
	// is redirecting requests for this information to another entity, usually temporarily.
	ErrRedirect = newStanzaError(302, modifyErrorType, redirectErrorReason)

	// ErrRegistrationRequired is returned by the stream when the requesting entity
	// is not authorized to access the requested service because registration is required.
	ErrRegistrationRequired = newStanzaError(407, authErrorType, registrationRequiredErrorReason)

	// ErrRemoteServerNotFound is returned by the stream when a remote server
	// or service specified as part or all of the JID of the intended recipient does not exist.
	ErrRemoteServerNotFound = newStanzaError(404, cancelErrorType, remoteServerNotFoundErrorReason)

	// ErrRemoteServerTimeout is returned by the stream when a remote server
	// or service specified as part or all of the JID of the intended recipient
	// could not be contacted within a reasonable amount of time.
	ErrRemoteServerTimeout = newStanzaError(504, waitErrorType, remoteServerTimeoutErrorReason)

	// ErrResourceConstraint is returned by the stream when the server or recipient
	// lacks the system resources necessary to service the request.
	ErrResourceConstraint = newStanzaError(500, waitErrorType, resourceConstraintErrorReason)

	// ErrServiceUnavailable is returned by the stream when the server or recipient
	// does not currently provide the requested service.
	ErrServiceUnavailable = newStanzaError(503, cancelErrorType, serviceUnavailableErrorReason)

	// ErrSubscriptionRequired is returned by the stream when the requesting entity
	// is not authorized to access the requested service because a subscription is required.
	ErrSubscriptionRequired = newStanzaError(407, authErrorType, subscriptionRequiredErrorReason)

	// ErrUndefinedCondition is returned by the stream when the error condition
	// is not one of those defined by the other conditions in this list.
	ErrUndefinedCondition = newStanzaError(500, waitErrorType, undefinedConditionErrorReason)

	// ErrUnexpectedCondition is returned by the stream when the recipient or server
	// understood the request but was not expecting it at this time.
	ErrUnexpectedCondition = newStanzaError(400, waitErrorType, unexpectedConditionErrorReason)

	// ErrUnexpectedRequest is returned by the stream when the recipient or server
	// understood the request but was not expecting it at this time.
	ErrUnexpectedRequest = newStanzaError(400, cancelErrorType, unexpectedRequestErrorReason)
)
View Source
var ErrStreamClosedByPeer = errors.New("xml: stream closed by peer")

ErrStreamClosedByPeer is returned by Parse when peer close the stream.

View Source
var ErrTooLargeStanza = errors.New("xml: too large stanza")

ErrTooLargeStanza is returned by ReadElement when the size of the incoming stanza is too large.

Functions

This section is empty.

Types

type Attribute

type Attribute struct {
	Label string
	Value string
}

Attribute represents an XML node attribute (label=value).

type AttributeSet

type AttributeSet interface {
	Get(string) string
	Count() int
}

AttributeSet interface represents a read-only set of XML attributes.

type Capabilities

type Capabilities struct {
	Node string
	Hash string
	Ver  string
}

Capabilities represents presence entity capabilities.

type Element

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

Element represents a generic and mutable XML node element.

func NewElementFromBytes

func NewElementFromBytes(buf *bytes.Buffer) (*Element, error)

NewElementFromBytes createsand returns a new Element from its bytes representation.

func NewElementFromElement

func NewElementFromElement(elem XElement) *Element

NewElementFromElement creates a mutable XML XElement by copying an element.

func NewElementName

func NewElementName(name string) *Element

NewElementName creates a mutable XML XElement instance with a given name.

func NewElementNamespace

func NewElementNamespace(name, namespace string) *Element

NewElementNamespace create a mutable XML XElement instance with a given name and namespace.

func (*Element) AppendElement

func (e *Element) AppendElement(element XElement) *Element

AppendElement appends a new sub element.

func (*Element) AppendElements

func (e *Element) AppendElements(elements []XElement) *Element

AppendElements appends an array of sub elements.

func (*Element) Attributes

func (e *Element) Attributes() AttributeSet

Attributes returns XML node attribute value.

func (*Element) ClearElements

func (e *Element) ClearElements() *Element

ClearElements removes all elements.

func (*Element) Delay

func (e *Element) Delay(from string, text string)

Delay attaches element's Delayed Delivery information.

func (*Element) Elements

func (e *Element) Elements() ElementSet

Elements returns all instance's child elements.

func (*Element) Error

func (e *Element) Error() XElement

Error returns element error sub element.

func (*Element) From

func (e *Element) From() string

From returns 'from' node attribute.

func (*Element) FromBytes

func (e *Element) FromBytes(buf *bytes.Buffer) error

FromBytes deserializes an element node from it's gob binary representation.

func (*Element) ID

func (e *Element) ID() string

ID returns 'id' node attribute.

func (*Element) IsError

func (e *Element) IsError() bool

IsError returns true if element has a 'type' attribute of value 'error'.

func (*Element) IsStanza

func (e *Element) IsStanza() bool

IsStanza returns true if element is an XMPP stanza.

func (*Element) Language

func (e *Element) Language() string

Language returns 'xml:lang' node attribute.

func (*Element) Name

func (e *Element) Name() string

Name returns XML node name.

func (*Element) Namespace

func (e *Element) Namespace() string

Namespace returns 'xmlns' node attribute.

func (*Element) RemoveAttribute

func (e *Element) RemoveAttribute(label string) *Element

RemoveAttribute removes an XML node attribute.

func (*Element) RemoveElements

func (e *Element) RemoveElements(name string) *Element

RemoveElements removes all elements with a given name.

func (*Element) RemoveElementsNamespace

func (e *Element) RemoveElementsNamespace(name, namespace string) *Element

RemoveElementsNamespace removes all elements with a given name and namespace.

func (*Element) SetAttribute

func (e *Element) SetAttribute(label, value string) *Element

SetAttribute sets an XML node attribute (label=value).

func (*Element) SetFrom

func (e *Element) SetFrom(from string) *Element

SetFrom sets 'from' node attribute.

func (*Element) SetID

func (e *Element) SetID(identifier string) *Element

SetID sets 'id' node attribute.

func (*Element) SetLanguage

func (e *Element) SetLanguage(language string) *Element

SetLanguage sets 'xml:lang' node attribute.

func (*Element) SetName

func (e *Element) SetName(name string) *Element

SetName sets XML node name.

func (*Element) SetNamespace

func (e *Element) SetNamespace(namespace string) *Element

SetNamespace sets 'xmlns' node attribute.

func (*Element) SetText

func (e *Element) SetText(text string) *Element

SetText sets XML node text value.

func (*Element) SetTo

func (e *Element) SetTo(to string) *Element

SetTo sets 'to' node attribute.

func (*Element) SetType

func (e *Element) SetType(tp string) *Element

SetType sets 'type' node attribute.

func (*Element) SetVersion

func (e *Element) SetVersion(version string) *Element

SetVersion sets 'version' node attribute.

func (*Element) String

func (e *Element) String() string

String returns a string representation of the element.

func (*Element) Text

func (e *Element) Text() string

Text returns XML node text value. Returns an empty string if not set.

func (*Element) To

func (e *Element) To() string

To returns 'to' node attribute.

func (*Element) ToBytes

func (e *Element) ToBytes(buf *bytes.Buffer) error

ToBytes serializes an element node to it's gob binary representation.

func (*Element) ToXML

func (e *Element) ToXML(w io.Writer, includeClosing bool) error

ToXML serializes element to a row XML representation. includeClosing determines if closing tag should be attached.

func (*Element) Type

func (e *Element) Type() string

Type returns 'type' node attribute.

func (*Element) Version

func (e *Element) Version() string

Version returns 'version' node attribute.

type ElementSet

type ElementSet interface {
	// Children returns all elements identified by name.
	// Returns an empty array if no elements are found.
	Children(name string) []XElement

	// Child returns first element identified by name.
	// Returns nill if no element is found.
	Child(name string) XElement

	// ChildrenNamespace returns all element identified by name and namespace.
	// Returns an empty array if no elements are found.
	ChildrenNamespace(name, namespace string) []XElement

	// ChildNamespace returns first element identified by name and namespace.
	// Returns an empty array if no elements are found.
	ChildNamespace(name, namespace string) XElement

	// All returns a list of all child nodes.
	All() []XElement

	// Count returns child elements count.
	Count() int
}

ElementSet interface represents a read-ony set of XMPP sub elements.

type IQ

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

IQ type represents an <iq> element. All incoming <iq> elements providing from the stream will automatically be converted to IQ objects.

func NewIQFromBytes

func NewIQFromBytes(buf *bytes.Buffer) (*IQ, error)

NewIQFromBytes creates and returns a new IQ element from its bytes representation.

func NewIQFromElement

func NewIQFromElement(e XElement, from *jid.JID, to *jid.JID) (*IQ, error)

NewIQFromElement creates an IQ object from XElement.

func NewIQType

func NewIQType(identifier string, iqType string) *IQ

NewIQType creates and returns a new IQ element.

func (*IQ) BadRequestError

func (s *IQ) BadRequestError() Stanza

BadRequestError returns an error copy of the element attaching 'bad-request' error sub element.

func (*IQ) ConflictError

func (s *IQ) ConflictError() Stanza

ConflictError returns an error copy of the element attaching 'conflict' error sub element.

func (*IQ) FeatureNotImplementedError

func (s *IQ) FeatureNotImplementedError() Stanza

FeatureNotImplementedError returns an error copy of the element attaching 'feature-not-implemented' error sub element.

func (*IQ) ForbiddenError

func (s *IQ) ForbiddenError() Stanza

ForbiddenError returns an error copy of the element attaching 'forbidden' error sub element.

func (*IQ) FromBytes

func (s *IQ) FromBytes(buf *bytes.Buffer) error

FromBytes deserializes a stanza element from it's gob binary representation.

func (*IQ) FromJID

func (s *IQ) FromJID() *jid.JID

FromJID returns presence 'from' JID value.

func (*IQ) GoneError

func (s *IQ) GoneError() Stanza

GoneError returns an error copy of the element attaching 'gone' error sub element.

func (*IQ) InternalServerError

func (s *IQ) InternalServerError() Stanza

InternalServerError returns an error copy of the element attaching 'internal-server-error' error sub element.

func (*IQ) IsGet

func (iq *IQ) IsGet() bool

IsGet returns true if this is a 'get' type IQ.

func (*IQ) IsResult

func (iq *IQ) IsResult() bool

IsResult returns true if this is a 'result' type IQ.

func (*IQ) IsSet

func (iq *IQ) IsSet() bool

IsSet returns true if this is a 'set' type IQ.

func (*IQ) ItemNotFoundError

func (s *IQ) ItemNotFoundError() Stanza

ItemNotFoundError returns an error copy of the element attaching 'item-not-found' error sub element.

func (*IQ) JidMalformedError

func (s *IQ) JidMalformedError() Stanza

JidMalformedError returns an error copy of the element attaching 'jid-malformed' error sub element.

func (*IQ) NotAcceptableError

func (s *IQ) NotAcceptableError() Stanza

NotAcceptableError returns an error copy of the element attaching 'not-acceptable' error sub element.

func (*IQ) NotAllowedError

func (s *IQ) NotAllowedError() Stanza

NotAllowedError returns an error copy of the element attaching 'not-allowed' error sub element.

func (*IQ) NotAuthorizedError

func (s *IQ) NotAuthorizedError() Stanza

NotAuthorizedError returns an error copy of the element attaching 'not-authorized' error sub element.

func (*IQ) PaymentRequiredError

func (s *IQ) PaymentRequiredError() Stanza

PaymentRequiredError returns an error copy of the element attaching 'payment-required' error sub element.

func (*IQ) RecipientUnavailableError

func (s *IQ) RecipientUnavailableError() Stanza

RecipientUnavailableError returns an error copy of the element attaching 'recipient-unavailable' error sub element.

func (*IQ) RedirectError

func (s *IQ) RedirectError() Stanza

RedirectError returns an error copy of the element attaching 'redirect' error sub element.

func (*IQ) RegistrationRequiredError

func (s *IQ) RegistrationRequiredError() Stanza

RegistrationRequiredError returns an error copy of the element attaching 'registration-required' error sub element.

func (*IQ) RemoteServerNotFoundError

func (s *IQ) RemoteServerNotFoundError() Stanza

RemoteServerNotFoundError returns an error copy of the element attaching 'remote-server-not-found' error sub element.

func (*IQ) RemoteServerTimeoutError

func (s *IQ) RemoteServerTimeoutError() Stanza

RemoteServerTimeoutError returns an error copy of the element attaching 'remote-server-timeout' error sub element.

func (*IQ) ResourceConstraintError

func (s *IQ) ResourceConstraintError() Stanza

ResourceConstraintError returns an error copy of the element attaching 'resource-constraint' error sub element.

func (*IQ) ResultIQ

func (iq *IQ) ResultIQ() *IQ

ResultIQ returns the instance associated result IQ.

func (*IQ) ServiceUnavailableError

func (s *IQ) ServiceUnavailableError() Stanza

ServiceUnavailableError returns an error copy of the element attaching 'service-unavailable' error sub element.

func (*IQ) SetFromJID

func (s *IQ) SetFromJID(j *jid.JID)

SetFromJID sets the IQ 'from' JID value.

func (*IQ) SetToJID

func (s *IQ) SetToJID(j *jid.JID)

SetToJID sets the IQ 'to' JID value.

func (*IQ) SubscriptionRequiredError

func (s *IQ) SubscriptionRequiredError() Stanza

SubscriptionRequiredError returns an error copy of the element attaching 'subscription-required' error sub element.

func (*IQ) ToJID

func (s *IQ) ToJID() *jid.JID

ToJID returns iq 'from' JID value.

func (*IQ) UndefinedConditionError

func (s *IQ) UndefinedConditionError() Stanza

UndefinedConditionError returns an error copy of the element attaching 'undefined-condition' error sub element.

func (*IQ) UnexpectedConditionError

func (s *IQ) UnexpectedConditionError() Stanza

UnexpectedConditionError returns an error copy of the element attaching 'unexpected-condition' error sub element.

func (*IQ) UnexpectedRequestError

func (s *IQ) UnexpectedRequestError() Stanza

UnexpectedRequestError returns an error copy of the element attaching 'unexpected-request' error sub element.

type Message

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

Message type represents a <message> element. All incoming <message> elements providing from the stream will automatically be converted to Message object.

func NewMessageFromBytes

func NewMessageFromBytes(buf *bytes.Buffer) (*Message, error)

NewMessageFromBytes creates and returns a new Message element from its bytes representation.

func NewMessageFromElement

func NewMessageFromElement(e XElement, from *jid.JID, to *jid.JID) (*Message, error)

NewMessageFromElement creates a Message object from XElement.

func NewMessageType

func NewMessageType(identifier string, messageType string) *Message

NewMessageType creates and returns a new Message element.

func (*Message) BadRequestError

func (s *Message) BadRequestError() Stanza

BadRequestError returns an error copy of the element attaching 'bad-request' error sub element.

func (*Message) ConflictError

func (s *Message) ConflictError() Stanza

ConflictError returns an error copy of the element attaching 'conflict' error sub element.

func (*Message) FeatureNotImplementedError

func (s *Message) FeatureNotImplementedError() Stanza

FeatureNotImplementedError returns an error copy of the element attaching 'feature-not-implemented' error sub element.

func (*Message) ForbiddenError

func (s *Message) ForbiddenError() Stanza

ForbiddenError returns an error copy of the element attaching 'forbidden' error sub element.

func (*Message) FromBytes

func (s *Message) FromBytes(buf *bytes.Buffer) error

FromBytes deserializes a stanza element from it's gob binary representation.

func (*Message) FromJID

func (s *Message) FromJID() *jid.JID

FromJID returns presence 'from' JID value.

func (*Message) GoneError

func (s *Message) GoneError() Stanza

GoneError returns an error copy of the element attaching 'gone' error sub element.

func (*Message) InternalServerError

func (s *Message) InternalServerError() Stanza

InternalServerError returns an error copy of the element attaching 'internal-server-error' error sub element.

func (*Message) IsChat

func (m *Message) IsChat() bool

IsChat returns true if this is a 'chat' type Message.

func (*Message) IsGroupChat

func (m *Message) IsGroupChat() bool

IsGroupChat returns true if this is a 'groupchat' type Message.

func (*Message) IsHeadline

func (m *Message) IsHeadline() bool

IsHeadline returns true if this is a 'headline' type Message.

func (*Message) IsMessageWithBody

func (m *Message) IsMessageWithBody() bool

IsMessageWithBody returns true if the message has a body sub element.

func (*Message) IsNormal

func (m *Message) IsNormal() bool

IsNormal returns true if this is a 'normal' type Message.

func (*Message) ItemNotFoundError

func (s *Message) ItemNotFoundError() Stanza

ItemNotFoundError returns an error copy of the element attaching 'item-not-found' error sub element.

func (*Message) JidMalformedError

func (s *Message) JidMalformedError() Stanza

JidMalformedError returns an error copy of the element attaching 'jid-malformed' error sub element.

func (*Message) NotAcceptableError

func (s *Message) NotAcceptableError() Stanza

NotAcceptableError returns an error copy of the element attaching 'not-acceptable' error sub element.

func (*Message) NotAllowedError

func (s *Message) NotAllowedError() Stanza

NotAllowedError returns an error copy of the element attaching 'not-allowed' error sub element.

func (*Message) NotAuthorizedError

func (s *Message) NotAuthorizedError() Stanza

NotAuthorizedError returns an error copy of the element attaching 'not-authorized' error sub element.

func (*Message) PaymentRequiredError

func (s *Message) PaymentRequiredError() Stanza

PaymentRequiredError returns an error copy of the element attaching 'payment-required' error sub element.

func (*Message) RecipientUnavailableError

func (s *Message) RecipientUnavailableError() Stanza

RecipientUnavailableError returns an error copy of the element attaching 'recipient-unavailable' error sub element.

func (*Message) RedirectError

func (s *Message) RedirectError() Stanza

RedirectError returns an error copy of the element attaching 'redirect' error sub element.

func (*Message) RegistrationRequiredError

func (s *Message) RegistrationRequiredError() Stanza

RegistrationRequiredError returns an error copy of the element attaching 'registration-required' error sub element.

func (*Message) RemoteServerNotFoundError

func (s *Message) RemoteServerNotFoundError() Stanza

RemoteServerNotFoundError returns an error copy of the element attaching 'remote-server-not-found' error sub element.

func (*Message) RemoteServerTimeoutError

func (s *Message) RemoteServerTimeoutError() Stanza

RemoteServerTimeoutError returns an error copy of the element attaching 'remote-server-timeout' error sub element.

func (*Message) ResourceConstraintError

func (s *Message) ResourceConstraintError() Stanza

ResourceConstraintError returns an error copy of the element attaching 'resource-constraint' error sub element.

func (*Message) ServiceUnavailableError

func (s *Message) ServiceUnavailableError() Stanza

ServiceUnavailableError returns an error copy of the element attaching 'service-unavailable' error sub element.

func (*Message) SetFromJID

func (s *Message) SetFromJID(j *jid.JID)

SetFromJID sets the IQ 'from' JID value.

func (*Message) SetToJID

func (s *Message) SetToJID(j *jid.JID)

SetToJID sets the IQ 'to' JID value.

func (*Message) SubscriptionRequiredError

func (s *Message) SubscriptionRequiredError() Stanza

SubscriptionRequiredError returns an error copy of the element attaching 'subscription-required' error sub element.

func (*Message) ToJID

func (s *Message) ToJID() *jid.JID

ToJID returns iq 'from' JID value.

func (*Message) UndefinedConditionError

func (s *Message) UndefinedConditionError() Stanza

UndefinedConditionError returns an error copy of the element attaching 'undefined-condition' error sub element.

func (*Message) UnexpectedConditionError

func (s *Message) UnexpectedConditionError() Stanza

UnexpectedConditionError returns an error copy of the element attaching 'unexpected-condition' error sub element.

func (*Message) UnexpectedRequestError

func (s *Message) UnexpectedRequestError() Stanza

UnexpectedRequestError returns an error copy of the element attaching 'unexpected-request' error sub element.

type Parser

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

Parser parses arbitrary XML input and builds an array with the structure of all tag and data element.

func NewParser

func NewParser(reader io.Reader, mode ParsingMode, maxStanzaSize int) *Parser

NewParser creates an empty Parser instance.

func (*Parser) ParseElement

func (p *Parser) ParseElement() (XElement, error)

ParseElement parses next available XML element from reader.

type ParsingMode

type ParsingMode int

ParsingMode defines the way in which special parsed element should be considered or not according to the reader nature.

type Presence

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

Presence type represents an <presence> element. All incoming <presence> elements providing from the stream will automatically be converted to Presence objects.

func NewPresence

func NewPresence(from *jid.JID, to *jid.JID, presenceType string) *Presence

NewPresence creates and returns a new Presence element.

func NewPresenceFromBytes

func NewPresenceFromBytes(buf *bytes.Buffer) (*Presence, error)

NewPresenceFromBytes creates and returns a new Presence element from its bytes representation.

func NewPresenceFromElement

func NewPresenceFromElement(e XElement, from *jid.JID, to *jid.JID) (*Presence, error)

NewPresenceFromElement creates a Presence object from XElement.

func (*Presence) BadRequestError

func (s *Presence) BadRequestError() Stanza

BadRequestError returns an error copy of the element attaching 'bad-request' error sub element.

func (*Presence) Capabilities

func (p *Presence) Capabilities() *Capabilities

Capabilities returns presence stanza capabilities element.

func (*Presence) ConflictError

func (s *Presence) ConflictError() Stanza

ConflictError returns an error copy of the element attaching 'conflict' error sub element.

func (*Presence) FeatureNotImplementedError

func (s *Presence) FeatureNotImplementedError() Stanza

FeatureNotImplementedError returns an error copy of the element attaching 'feature-not-implemented' error sub element.

func (*Presence) ForbiddenError

func (s *Presence) ForbiddenError() Stanza

ForbiddenError returns an error copy of the element attaching 'forbidden' error sub element.

func (*Presence) FromBytes

func (s *Presence) FromBytes(buf *bytes.Buffer) error

FromBytes deserializes a stanza element from it's gob binary representation.

func (*Presence) FromJID

func (s *Presence) FromJID() *jid.JID

FromJID returns presence 'from' JID value.

func (*Presence) GoneError

func (s *Presence) GoneError() Stanza

GoneError returns an error copy of the element attaching 'gone' error sub element.

func (*Presence) InternalServerError

func (s *Presence) InternalServerError() Stanza

InternalServerError returns an error copy of the element attaching 'internal-server-error' error sub element.

func (*Presence) IsAvailable

func (p *Presence) IsAvailable() bool

IsAvailable returns true if this is an 'available' type Presence.

func (*Presence) IsProbe

func (p *Presence) IsProbe() bool

IsProbe returns true if this is an 'probe' type Presence.

func (*Presence) IsSubscribe

func (p *Presence) IsSubscribe() bool

IsSubscribe returns true if this is an 'subscribe' type Presence.

func (*Presence) IsSubscribed

func (p *Presence) IsSubscribed() bool

IsSubscribed returns true if this is an 'subscribed' type Presence.

func (*Presence) IsUnavailable

func (p *Presence) IsUnavailable() bool

IsUnavailable returns true if this is an 'unavailable' type Presence.

func (*Presence) IsUnsubscribe

func (p *Presence) IsUnsubscribe() bool

IsUnsubscribe returns true if this is an 'unsubscribe' type Presence.

func (*Presence) IsUnsubscribed

func (p *Presence) IsUnsubscribed() bool

IsUnsubscribed returns true if this is an 'unsubscribed' type Presence.

func (*Presence) ItemNotFoundError

func (s *Presence) ItemNotFoundError() Stanza

ItemNotFoundError returns an error copy of the element attaching 'item-not-found' error sub element.

func (*Presence) JidMalformedError

func (s *Presence) JidMalformedError() Stanza

JidMalformedError returns an error copy of the element attaching 'jid-malformed' error sub element.

func (*Presence) NotAcceptableError

func (s *Presence) NotAcceptableError() Stanza

NotAcceptableError returns an error copy of the element attaching 'not-acceptable' error sub element.

func (*Presence) NotAllowedError

func (s *Presence) NotAllowedError() Stanza

NotAllowedError returns an error copy of the element attaching 'not-allowed' error sub element.

func (*Presence) NotAuthorizedError

func (s *Presence) NotAuthorizedError() Stanza

NotAuthorizedError returns an error copy of the element attaching 'not-authorized' error sub element.

func (*Presence) PaymentRequiredError

func (s *Presence) PaymentRequiredError() Stanza

PaymentRequiredError returns an error copy of the element attaching 'payment-required' error sub element.

func (*Presence) Priority

func (p *Presence) Priority() int8

Priority returns presence stanza priority value.

func (*Presence) RecipientUnavailableError

func (s *Presence) RecipientUnavailableError() Stanza

RecipientUnavailableError returns an error copy of the element attaching 'recipient-unavailable' error sub element.

func (*Presence) RedirectError

func (s *Presence) RedirectError() Stanza

RedirectError returns an error copy of the element attaching 'redirect' error sub element.

func (*Presence) RegistrationRequiredError

func (s *Presence) RegistrationRequiredError() Stanza

RegistrationRequiredError returns an error copy of the element attaching 'registration-required' error sub element.

func (*Presence) RemoteServerNotFoundError

func (s *Presence) RemoteServerNotFoundError() Stanza

RemoteServerNotFoundError returns an error copy of the element attaching 'remote-server-not-found' error sub element.

func (*Presence) RemoteServerTimeoutError

func (s *Presence) RemoteServerTimeoutError() Stanza

RemoteServerTimeoutError returns an error copy of the element attaching 'remote-server-timeout' error sub element.

func (*Presence) ResourceConstraintError

func (s *Presence) ResourceConstraintError() Stanza

ResourceConstraintError returns an error copy of the element attaching 'resource-constraint' error sub element.

func (*Presence) ServiceUnavailableError

func (s *Presence) ServiceUnavailableError() Stanza

ServiceUnavailableError returns an error copy of the element attaching 'service-unavailable' error sub element.

func (*Presence) SetFromJID

func (s *Presence) SetFromJID(j *jid.JID)

SetFromJID sets the IQ 'from' JID value.

func (*Presence) SetToJID

func (s *Presence) SetToJID(j *jid.JID)

SetToJID sets the IQ 'to' JID value.

func (*Presence) ShowState

func (p *Presence) ShowState() ShowState

ShowState returns presence stanza show state.

func (*Presence) Status

func (p *Presence) Status() string

Status returns presence stanza default status.

func (*Presence) SubscriptionRequiredError

func (s *Presence) SubscriptionRequiredError() Stanza

SubscriptionRequiredError returns an error copy of the element attaching 'subscription-required' error sub element.

func (*Presence) ToJID

func (s *Presence) ToJID() *jid.JID

ToJID returns iq 'from' JID value.

func (*Presence) UndefinedConditionError

func (s *Presence) UndefinedConditionError() Stanza

UndefinedConditionError returns an error copy of the element attaching 'undefined-condition' error sub element.

func (*Presence) UnexpectedConditionError

func (s *Presence) UnexpectedConditionError() Stanza

UnexpectedConditionError returns an error copy of the element attaching 'unexpected-condition' error sub element.

func (*Presence) UnexpectedRequestError

func (s *Presence) UnexpectedRequestError() Stanza

UnexpectedRequestError returns an error copy of the element attaching 'unexpected-request' error sub element.

type ShowState

type ShowState int

ShowState represents Presence show state.

const (
	// AvailableShowState represents 'available' Presence show state.
	AvailableShowState ShowState = iota

	// AwayShowState represents 'away' Presence show state.
	AwayShowState

	// ChatShowState represents 'chat' Presence show state.
	ChatShowState

	// DoNotDisturbShowState represents 'dnd' Presence show state.
	DoNotDisturbShowState

	// ExtendedAwayShowState represents 'xa' Presence show state.
	ExtendedAwayShowState
)

type Stanza

type Stanza interface {
	XElement
	FromJID() *jid.JID
	ToJID() *jid.JID
}

Stanza represents an XMPP stanza element.

func NewErrorStanzaFromStanza

func NewErrorStanzaFromStanza(stanza Stanza, stanzaErr *StanzaError, errorElements []XElement) Stanza

NewErrorStanzaFromStanza returns a copy of an element of stanza error class.

func NewStanzaFromElement

func NewStanzaFromElement(elem XElement) (Stanza, error)

NewStanzaFromElement returns a new stanza instance derived from an XMPP element.

type StanzaError

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

StanzaError represents a stanza "error" element.

func (*StanzaError) Element

func (se *StanzaError) Element() *Element

Element returns StanzaError equivalent XML element.

func (*StanzaError) Error

func (se *StanzaError) Error() string

Error satisfies error interface.

type XElement

type XElement interface {
	fmt.Stringer

	Name() string
	Attributes() AttributeSet
	Elements() ElementSet

	Text() string

	ID() string
	Namespace() string
	Language() string
	Version() string
	From() string
	To() string
	Type() string

	IsStanza() bool

	IsError() bool
	Error() XElement

	ToXML(w io.Writer, includeClosing bool) error
	ToBytes(buf *bytes.Buffer) error
}

XElement represents a generic XML node element.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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