xmpp

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2018 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

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

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

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

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

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

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

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

	// ProbeType represents a '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 possess 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)
)
View Source
var ErrStreamClosedByPeer = errors.New("xml: stream closed by peer")

ErrStreamClosedByPeer is returned by Parse when peer closes 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 Element

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

Element represents a generic and mutable XML node element.

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 creates a mutable XML XElement instance with a given name and namespace.

func (*Element) AppendElement

func (e *Element) AppendElement(element XElement)

AppendElement appends a new sub element.

func (*Element) AppendElements

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

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()

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) FromGob

func (e *Element) FromGob(dec *gob.Decoder)

FromGob 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

Domain 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)

RemoveAttribute removes an XML node attribute.

func (*Element) RemoveElements

func (e *Element) RemoveElements(name string)

RemoveElements removes all elements with a given name.

func (*Element) RemoveElementsNamespace

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

RemoveElementsNamespace removes all elements with a given name and namespace.

func (*Element) SetAttribute

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

SetAttribute sets an XML node attribute (label=value)

func (*Element) SetFrom

func (e *Element) SetFrom(from string)

SetFrom sets 'from' node attribute.

func (*Element) SetID

func (e *Element) SetID(identifier string)

SetID sets 'id' node attribute.

func (*Element) SetLanguage

func (e *Element) SetLanguage(language string)

SetLanguage sets 'xml:lang' node attribute.

func (*Element) SetName

func (e *Element) SetName(name string)

SetName sets XML node name.

func (*Element) SetNamespace

func (e *Element) SetNamespace(namespace string)

SetNamespace sets 'xmlns' node attribute.

func (*Element) SetText

func (e *Element) SetText(text string)

SetText sets XML node text value.

func (*Element) SetTo

func (e *Element) SetTo(to string)

SetTo sets 'to' node attribute.

func (*Element) SetType

func (e *Element) SetType(tp string)

SetType sets 'type' node attribute.

func (*Element) SetVersion

func (e *Element) SetVersion(version string)

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) ToGob

func (e *Element) ToGob(enc *gob.Encoder)

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

func (*Element) ToXML

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

ToXML serializes element to a raw 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 nil if no element is found.
	Child(name string) XElement

	// ChildrenNamespace returns all elements 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 nil if no element is 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-only set of XML 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 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 (stanza *IQ) BadRequestError() Stanza

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

func (*IQ) ConflictError

func (stanza *IQ) ConflictError() Stanza

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

func (*IQ) FeatureNotImplementedError

func (stanza *IQ) FeatureNotImplementedError() Stanza

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

func (*IQ) ForbiddenError

func (stanza *IQ) ForbiddenError() Stanza

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

func (*IQ) FromJID

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

FromJID returns presence 'from' JID value.

func (*IQ) GoneError

func (stanza *IQ) GoneError() Stanza

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

func (*IQ) InternalServerError

func (stanza *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 (stanza *IQ) ItemNotFoundError() Stanza

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

func (*IQ) JidMalformedError

func (stanza *IQ) JidMalformedError() Stanza

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

func (*IQ) NotAcceptableError

func (stanza *IQ) NotAcceptableError() Stanza

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

func (*IQ) NotAllowedError

func (stanza *IQ) NotAllowedError() Stanza

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

func (*IQ) NotAuthorizedError

func (stanza *IQ) NotAuthorizedError() Stanza

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

func (*IQ) PaymentRequiredError

func (stanza *IQ) PaymentRequiredError() Stanza

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

func (*IQ) RecipientUnavailableError

func (stanza *IQ) RecipientUnavailableError() Stanza

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

func (*IQ) RedirectError

func (stanza *IQ) RedirectError() Stanza

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

func (*IQ) RegistrationRequiredError

func (stanza *IQ) RegistrationRequiredError() Stanza

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

func (*IQ) RemoteServerNotFoundError

func (stanza *IQ) RemoteServerNotFoundError() Stanza

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

func (*IQ) RemoteServerTimeoutError

func (stanza *IQ) RemoteServerTimeoutError() Stanza

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

func (*IQ) ResourceConstraintError

func (stanza *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 (stanza *IQ) ServiceUnavailableError() Stanza

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

func (*IQ) SetFromJID

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

SetFromJID sets the IQ 'from' JID value.

func (*IQ) SetToJID

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

SetToJID sets the IQ 'to' JID value.

func (*IQ) SubscriptionRequiredError

func (stanza *IQ) SubscriptionRequiredError() Stanza

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

func (*IQ) ToJID

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

ToJID returns iq 'from' JID value.

func (*IQ) UndefinedConditionError

func (stanza *IQ) UndefinedConditionError() Stanza

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

func (*IQ) UnexpectedConditionError

func (stanza *IQ) UnexpectedConditionError() Stanza

UnexpectedConditionError returns an error copy of the element attaching 'unexpected-condition' 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 objects.

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 (stanza *Message) BadRequestError() Stanza

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

func (*Message) ConflictError

func (stanza *Message) ConflictError() Stanza

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

func (*Message) FeatureNotImplementedError

func (stanza *Message) FeatureNotImplementedError() Stanza

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

func (*Message) ForbiddenError

func (stanza *Message) ForbiddenError() Stanza

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

func (*Message) FromJID

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

FromJID returns presence 'from' JID value.

func (*Message) GoneError

func (stanza *Message) GoneError() Stanza

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

func (*Message) InternalServerError

func (stanza *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 (stanza *Message) ItemNotFoundError() Stanza

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

func (*Message) JidMalformedError

func (stanza *Message) JidMalformedError() Stanza

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

func (*Message) NotAcceptableError

func (stanza *Message) NotAcceptableError() Stanza

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

func (*Message) NotAllowedError

func (stanza *Message) NotAllowedError() Stanza

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

func (*Message) NotAuthorizedError

func (stanza *Message) NotAuthorizedError() Stanza

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

func (*Message) PaymentRequiredError

func (stanza *Message) PaymentRequiredError() Stanza

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

func (*Message) RecipientUnavailableError

func (stanza *Message) RecipientUnavailableError() Stanza

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

func (*Message) RedirectError

func (stanza *Message) RedirectError() Stanza

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

func (*Message) RegistrationRequiredError

func (stanza *Message) RegistrationRequiredError() Stanza

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

func (*Message) RemoteServerNotFoundError

func (stanza *Message) RemoteServerNotFoundError() Stanza

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

func (*Message) RemoteServerTimeoutError

func (stanza *Message) RemoteServerTimeoutError() Stanza

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

func (*Message) ResourceConstraintError

func (stanza *Message) ResourceConstraintError() Stanza

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

func (*Message) ServiceUnavailableError

func (stanza *Message) ServiceUnavailableError() Stanza

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

func (*Message) SetFromJID

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

SetFromJID sets the IQ 'from' JID value.

func (*Message) SetToJID

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

SetToJID sets the IQ 'to' JID value.

func (*Message) SubscriptionRequiredError

func (stanza *Message) SubscriptionRequiredError() Stanza

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

func (*Message) ToJID

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

ToJID returns iq 'from' JID value.

func (*Message) UndefinedConditionError

func (stanza *Message) UndefinedConditionError() Stanza

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

func (*Message) UnexpectedConditionError

func (stanza *Message) UnexpectedConditionError() Stanza

UnexpectedConditionError returns an error copy of the element attaching 'unexpected-condition' 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 elements.

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 NewPresenceFromElement

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

NewPresenceFromElement creates a Presence object from XElement.

func (*Presence) BadRequestError

func (stanza *Presence) BadRequestError() Stanza

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

func (*Presence) ConflictError

func (stanza *Presence) ConflictError() Stanza

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

func (*Presence) FeatureNotImplementedError

func (stanza *Presence) FeatureNotImplementedError() Stanza

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

func (*Presence) ForbiddenError

func (stanza *Presence) ForbiddenError() Stanza

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

func (*Presence) FromJID

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

FromJID returns presence 'from' JID value.

func (*Presence) GoneError

func (stanza *Presence) GoneError() Stanza

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

func (*Presence) InternalServerError

func (stanza *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 a 'subscribe' type Presence.

func (*Presence) IsSubscribed

func (p *Presence) IsSubscribed() bool

IsSubscribed returns true if this is a '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 (stanza *Presence) ItemNotFoundError() Stanza

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

func (*Presence) JidMalformedError

func (stanza *Presence) JidMalformedError() Stanza

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

func (*Presence) NotAcceptableError

func (stanza *Presence) NotAcceptableError() Stanza

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

func (*Presence) NotAllowedError

func (stanza *Presence) NotAllowedError() Stanza

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

func (*Presence) NotAuthorizedError

func (stanza *Presence) NotAuthorizedError() Stanza

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

func (*Presence) PaymentRequiredError

func (stanza *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 (stanza *Presence) RecipientUnavailableError() Stanza

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

func (*Presence) RedirectError

func (stanza *Presence) RedirectError() Stanza

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

func (*Presence) RegistrationRequiredError

func (stanza *Presence) RegistrationRequiredError() Stanza

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

func (*Presence) RemoteServerNotFoundError

func (stanza *Presence) RemoteServerNotFoundError() Stanza

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

func (*Presence) RemoteServerTimeoutError

func (stanza *Presence) RemoteServerTimeoutError() Stanza

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

func (*Presence) ResourceConstraintError

func (stanza *Presence) ResourceConstraintError() Stanza

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

func (*Presence) ServiceUnavailableError

func (stanza *Presence) ServiceUnavailableError() Stanza

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

func (*Presence) SetFromJID

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

SetFromJID sets the IQ 'from' JID value.

func (*Presence) SetToJID

func (stanza *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 (stanza *Presence) SubscriptionRequiredError() Stanza

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

func (*Presence) ToJID

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

ToJID returns iq 'from' JID value.

func (*Presence) UndefinedConditionError

func (stanza *Presence) UndefinedConditionError() Stanza

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

func (*Presence) UnexpectedConditionError

func (stanza *Presence) UnexpectedConditionError() Stanza

UnexpectedConditionError returns an error copy of the element attaching 'unexpected-condition' 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

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

type Stanza

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

func NewErrorStanzaFromStanza

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

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

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)
	ToGob(enc *gob.Encoder)
}

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