Documentation ¶
Index ¶
- Constants
- Variables
- type Attribute
- type Element
- type IQ
- func (e *IQ) Attribute(label string) string
- func (e *IQ) Attributes() []Attribute
- func (e *IQ) AttributesCount() int
- func (el *IQ) BadRequestError() Element
- func (el *IQ) ConflictError() Element
- func (e *IQ) Copy() *MutableElement
- func (e *IQ) Elements() []Element
- func (e *IQ) ElementsCount() int
- func (e *IQ) Error() Element
- func (el *IQ) FeatureNotImplementedError() Element
- func (e *IQ) FindElement(name string) Element
- func (e *IQ) FindElementNamespace(name, namespace string) Element
- func (e *IQ) FindElements(name string) []Element
- func (e *IQ) FindElementsNamespace(name, namespace string) []Element
- func (el *IQ) ForbiddenError() Element
- func (e *IQ) From() string
- func (e *IQ) FromBytes(r io.Reader)
- func (iq *IQ) FromJID() *JID
- func (el *IQ) GoneError() Element
- func (e *IQ) ID() string
- func (el *IQ) InternalServerError() Element
- func (e *IQ) IsError() bool
- func (iq *IQ) IsGet() bool
- func (iq *IQ) IsResult() bool
- func (iq *IQ) IsSet() bool
- func (el *IQ) ItemNotFoundError() Element
- func (el *IQ) JidMalformedError() Element
- func (e *IQ) Language() string
- func (e *IQ) Name() string
- func (e *IQ) Namespace() string
- func (el *IQ) NotAcceptableError() Element
- func (el *IQ) NotAllowedError() Element
- func (el *IQ) NotAuthorizedError() Element
- func (el *IQ) PaymentRequiredError() Element
- func (el *IQ) RecipientUnavailableError() Element
- func (el *IQ) RedirectError() Element
- func (el *IQ) RegistrationRequiredError() Element
- func (el *IQ) RemoteServerNotFoundError() Element
- func (el *IQ) RemoteServerTimeoutError() Element
- func (el *IQ) ResourceConstraintError() Element
- func (iq *IQ) ResultIQ() *IQ
- func (el *IQ) ServiceUnavailableError() Element
- func (iq *IQ) SetFromJID(from *JID)
- func (iq *IQ) SetToJID(to *JID)
- func (e *IQ) String() string
- func (el *IQ) SubscriptionRequiredError() Element
- func (e *IQ) Text() string
- func (e *IQ) TextLen() int
- func (e *IQ) To() string
- func (e *IQ) ToBytes(w io.Writer)
- func (el *IQ) ToError(stanzaError *StanzaError) Element
- func (iq *IQ) ToJID() *JID
- func (e *IQ) ToXML(w io.Writer, includeClosing bool)
- func (e *IQ) Type() string
- func (el *IQ) UndefinedConditionError() Element
- func (el *IQ) UnexpectedConditionError() Element
- func (e *IQ) Version() string
- type JID
- type Message
- func (e *Message) Attribute(label string) string
- func (e *Message) Attributes() []Attribute
- func (e *Message) AttributesCount() int
- func (el *Message) BadRequestError() Element
- func (el *Message) ConflictError() Element
- func (e *Message) Copy() *MutableElement
- func (e *Message) Elements() []Element
- func (e *Message) ElementsCount() int
- func (e *Message) Error() Element
- func (el *Message) FeatureNotImplementedError() Element
- func (e *Message) FindElement(name string) Element
- func (e *Message) FindElementNamespace(name, namespace string) Element
- func (e *Message) FindElements(name string) []Element
- func (e *Message) FindElementsNamespace(name, namespace string) []Element
- func (el *Message) ForbiddenError() Element
- func (e *Message) From() string
- func (e *Message) FromBytes(r io.Reader)
- func (m *Message) FromJID() *JID
- func (el *Message) GoneError() Element
- func (e *Message) ID() string
- func (el *Message) InternalServerError() Element
- func (m *Message) IsChat() bool
- func (e *Message) IsError() bool
- func (m *Message) IsGroupChat() bool
- func (m *Message) IsHeadline() bool
- func (m *Message) IsMessageWithBody() bool
- func (m *Message) IsNormal() bool
- func (el *Message) ItemNotFoundError() Element
- func (el *Message) JidMalformedError() Element
- func (e *Message) Language() string
- func (e *Message) Name() string
- func (e *Message) Namespace() string
- func (el *Message) NotAcceptableError() Element
- func (el *Message) NotAllowedError() Element
- func (el *Message) NotAuthorizedError() Element
- func (el *Message) PaymentRequiredError() Element
- func (el *Message) RecipientUnavailableError() Element
- func (el *Message) RedirectError() Element
- func (el *Message) RegistrationRequiredError() Element
- func (el *Message) RemoteServerNotFoundError() Element
- func (el *Message) RemoteServerTimeoutError() Element
- func (el *Message) ResourceConstraintError() Element
- func (el *Message) ServiceUnavailableError() Element
- func (m *Message) SetFromJID(from *JID)
- func (m *Message) SetToJID(to *JID)
- func (e *Message) String() string
- func (el *Message) SubscriptionRequiredError() Element
- func (e *Message) Text() string
- func (e *Message) TextLen() int
- func (e *Message) To() string
- func (e *Message) ToBytes(w io.Writer)
- func (el *Message) ToError(stanzaError *StanzaError) Element
- func (m *Message) ToJID() *JID
- func (e *Message) ToXML(w io.Writer, includeClosing bool)
- func (e *Message) Type() string
- func (el *Message) UndefinedConditionError() Element
- func (el *Message) UnexpectedConditionError() Element
- func (e *Message) Version() string
- type MutableElement
- func (m *MutableElement) AppendElement(element Element)
- func (m *MutableElement) AppendElements(elements []Element)
- func (e *MutableElement) Attribute(label string) string
- func (e *MutableElement) Attributes() []Attribute
- func (e *MutableElement) AttributesCount() int
- func (el *MutableElement) BadRequestError() Element
- func (m *MutableElement) ClearElements()
- func (el *MutableElement) ConflictError() Element
- func (e *MutableElement) Copy() *MutableElement
- func (m *MutableElement) Delay(from string, text string)
- func (e *MutableElement) Elements() []Element
- func (e *MutableElement) ElementsCount() int
- func (e *MutableElement) Error() Element
- func (el *MutableElement) FeatureNotImplementedError() Element
- func (e *MutableElement) FindElement(name string) Element
- func (e *MutableElement) FindElementNamespace(name, namespace string) Element
- func (e *MutableElement) FindElements(name string) []Element
- func (e *MutableElement) FindElementsNamespace(name, namespace string) []Element
- func (el *MutableElement) ForbiddenError() Element
- func (e *MutableElement) From() string
- func (e *MutableElement) FromBytes(r io.Reader)
- func (el *MutableElement) GoneError() Element
- func (e *MutableElement) ID() string
- func (el *MutableElement) InternalServerError() Element
- func (e *MutableElement) IsError() bool
- func (el *MutableElement) ItemNotFoundError() Element
- func (el *MutableElement) JidMalformedError() Element
- func (e *MutableElement) Language() string
- func (e *MutableElement) Name() string
- func (e *MutableElement) Namespace() string
- func (el *MutableElement) NotAcceptableError() Element
- func (el *MutableElement) NotAllowedError() Element
- func (el *MutableElement) NotAuthorizedError() Element
- func (el *MutableElement) PaymentRequiredError() Element
- func (el *MutableElement) RecipientUnavailableError() Element
- func (el *MutableElement) RedirectError() Element
- func (el *MutableElement) RegistrationRequiredError() Element
- func (el *MutableElement) RemoteServerNotFoundError() Element
- func (el *MutableElement) RemoteServerTimeoutError() Element
- func (m *MutableElement) RemoveAttribute(label string)
- func (m *MutableElement) RemoveElements(name string)
- func (m *MutableElement) RemoveElementsNamespace(name, namespace string)
- func (el *MutableElement) ResourceConstraintError() Element
- func (el *MutableElement) ServiceUnavailableError() Element
- func (m *MutableElement) SetAttribute(label, value string)
- func (m *MutableElement) SetFrom(from string)
- func (m *MutableElement) SetID(identifier string)
- func (m *MutableElement) SetLanguage(language string)
- func (m *MutableElement) SetName(name string)
- func (m *MutableElement) SetNamespace(namespace string)
- func (m *MutableElement) SetText(text string)
- func (m *MutableElement) SetTo(to string)
- func (m *MutableElement) SetType(tp string)
- func (m *MutableElement) SetVersion(version string)
- func (e *MutableElement) String() string
- func (el *MutableElement) SubscriptionRequiredError() Element
- func (e *MutableElement) Text() string
- func (e *MutableElement) TextLen() int
- func (e *MutableElement) To() string
- func (e *MutableElement) ToBytes(w io.Writer)
- func (el *MutableElement) ToError(stanzaError *StanzaError) Element
- func (e *MutableElement) ToXML(w io.Writer, includeClosing bool)
- func (e *MutableElement) Type() string
- func (el *MutableElement) UndefinedConditionError() Element
- func (el *MutableElement) UnexpectedConditionError() Element
- func (e *MutableElement) Version() string
- type Parser
- type Presence
- func (e *Presence) Attribute(label string) string
- func (e *Presence) Attributes() []Attribute
- func (e *Presence) AttributesCount() int
- func (el *Presence) BadRequestError() Element
- func (el *Presence) ConflictError() Element
- func (e *Presence) Copy() *MutableElement
- func (e *Presence) Elements() []Element
- func (e *Presence) ElementsCount() int
- func (e *Presence) Error() Element
- func (el *Presence) FeatureNotImplementedError() Element
- func (e *Presence) FindElement(name string) Element
- func (e *Presence) FindElementNamespace(name, namespace string) Element
- func (e *Presence) FindElements(name string) []Element
- func (e *Presence) FindElementsNamespace(name, namespace string) []Element
- func (el *Presence) ForbiddenError() Element
- func (e *Presence) From() string
- func (e *Presence) FromBytes(r io.Reader)
- func (p *Presence) FromJID() *JID
- func (el *Presence) GoneError() Element
- func (e *Presence) ID() string
- func (el *Presence) InternalServerError() Element
- func (p *Presence) IsAvailable() bool
- func (e *Presence) IsError() bool
- func (p *Presence) IsSubscribe() bool
- func (p *Presence) IsSubscribed() bool
- func (p *Presence) IsUnavailable() bool
- func (p *Presence) IsUnsubscribe() bool
- func (p *Presence) IsUnsubscribed() bool
- func (el *Presence) ItemNotFoundError() Element
- func (el *Presence) JidMalformedError() Element
- func (e *Presence) Language() string
- func (e *Presence) Name() string
- func (e *Presence) Namespace() string
- func (el *Presence) NotAcceptableError() Element
- func (el *Presence) NotAllowedError() Element
- func (el *Presence) NotAuthorizedError() Element
- func (el *Presence) PaymentRequiredError() Element
- func (p *Presence) Priority() int8
- func (el *Presence) RecipientUnavailableError() Element
- func (el *Presence) RedirectError() Element
- func (el *Presence) RegistrationRequiredError() Element
- func (el *Presence) RemoteServerNotFoundError() Element
- func (el *Presence) RemoteServerTimeoutError() Element
- func (el *Presence) ResourceConstraintError() Element
- func (el *Presence) ServiceUnavailableError() Element
- func (p *Presence) SetFromJID(from *JID)
- func (p *Presence) SetToJID(to *JID)
- func (p *Presence) ShowState() ShowState
- func (e *Presence) String() string
- func (el *Presence) SubscriptionRequiredError() Element
- func (e *Presence) Text() string
- func (e *Presence) TextLen() int
- func (e *Presence) To() string
- func (e *Presence) ToBytes(w io.Writer)
- func (el *Presence) ToError(stanzaError *StanzaError) Element
- func (p *Presence) ToJID() *JID
- func (e *Presence) ToXML(w io.Writer, includeClosing bool)
- func (e *Presence) Type() string
- func (el *Presence) UndefinedConditionError() Element
- func (el *Presence) UnexpectedConditionError() Element
- func (e *Presence) Version() string
- type ShowState
- type StanzaError
Constants ¶
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" )
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" )
const ( // AvailableType represents an 'available' Presence type. AvailableType = "available" 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" )
const ErrorType = "error"
ErrorType represents an 'error' stanza type.
Variables ¶
var ( // ErrBadRequest is returned by the stream when the sender // has sent XML that is malformed or that cannot be processed. ErrBadRequest = newErrorElement(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 = newErrorElement(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 = newErrorElement(501, cancelErrorType, featureNotImplementedErrorReason) // ErrForbidden is returned by the stream when the requesting // entity does not possess the required permissions to perform the action. ErrForbidden = newErrorElement(403, authErrorType, forbiddenErrorReason) // ErrGone is returned by the stream when the recipient or server // can no longer be contacted at this address. ErrGone = newErrorElement(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 = newErrorElement(500, waitErrorType, internalServerErrorErrorReason) // ErrItemNotFound is returned by the stream when the addressed // JID or item requested cannot be found. ErrItemNotFound = newErrorElement(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 = newErrorElement(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 = newErrorElement(406, modifyErrorType, notAcceptableErrorReason) // ErrNotAllowed is returned by the stream when the recipient // or server does not allow any entity to perform the action. ErrNotAllowed = newErrorElement(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 = newErrorElement(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 = newErrorElement(402, authErrorType, paymentRequiredErrorReason) // recipient is temporarily unavailable. ErrRecipientUnavailable = newErrorElement(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 = newErrorElement(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 = newErrorElement(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 = newErrorElement(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 = newErrorElement(504, waitErrorType, remoteServerTimeoutErrorReason) // ErrResourceConstraint is returned by the stream when the server or recipient // lacks the system resources necessary to service the request. ErrResourceConstraint = newErrorElement(500, waitErrorType, resourceConstraintErrorReason) // does not currently provide the requested service. ErrServiceUnavailable = newErrorElement(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 = newErrorElement(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 = newErrorElement(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 = newErrorElement(400, waitErrorType, unexpectedConditionErrorReason) )
var ErrStreamClosedByPeer = errors.New("stream closed by peer")
ErrStreamClosedByPeer is returned by Parse when peer closes the stream by sending '</stream:stream>' closing tag.
Functions ¶
This section is empty.
Types ¶
type Element ¶
type Element interface { fmt.Stringer Name() string Namespace() string ID() string Language() string Version() string From() string To() string Type() string Text() string TextLen() int Attribute(label string) string Attributes() []Attribute AttributesCount() int FindElement(name string) Element FindElements(name string) []Element FindElementNamespace(name, namespace string) Element FindElementsNamespace(name, namespace string) []Element Elements() []Element ElementsCount() int ToError(stanzaError *StanzaError) Element Error() Element ToXML(writer io.Writer, includeClosing bool) FromBytes(r io.Reader) ToBytes(w io.Writer) }
Element represents an XML node element.
type IQ ¶
type IQ struct { MutableElement // 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 ¶
NewIQFromElement creates an IQ object from Element.
func (*IQ) Attributes ¶
func (e *IQ) Attributes() []Attribute
Attributes returns all XML node attributes.
func (*IQ) AttributesCount ¶
func (e *IQ) AttributesCount() int
AttributesCount XML attributes count.
func (*IQ) BadRequestError ¶
func (el *IQ) BadRequestError() Element
BadRequestError returns an error copy of the element attaching 'bad-request' error sub element.
func (*IQ) ConflictError ¶
func (el *IQ) ConflictError() Element
ConflictError returns an error copy of the element attaching 'conflict' error sub element.
func (*IQ) Copy ¶
func (e *IQ) Copy() *MutableElement
Copy returns a deep copy of this message stanza.
func (*IQ) Elements ¶
func (e *IQ) Elements() []Element
Elements returns all instance's child elements.
func (*IQ) ElementsCount ¶
func (e *IQ) ElementsCount() int
ElementsCount returns child elements count.
func (*IQ) FeatureNotImplementedError ¶
func (el *IQ) FeatureNotImplementedError() Element
FeatureNotImplementedError returns an error copy of the element attaching 'feature-not-implemented' error sub element.
func (*IQ) FindElement ¶
FindElement returns first element identified by name. Returns nil if no element is found.
func (*IQ) FindElementNamespace ¶
FindElementNamespace returns first element identified by name and namespace. Returns nil if no element is found.
func (*IQ) FindElements ¶
FindElements returns all elements identified by name. Returns an empty array if no elements are found.
func (*IQ) FindElementsNamespace ¶
FindElementsNamespace returns all elements identified by name and namespace. Returns an empty array if no elements are found.
func (*IQ) ForbiddenError ¶
func (el *IQ) ForbiddenError() Element
ForbiddenError returns an error copy of the element attaching 'forbidden' error sub element.
func (*IQ) GoneError ¶
func (el *IQ) GoneError() Element
GoneError returns an error copy of the element attaching 'gone' error sub element.
func (*IQ) InternalServerError ¶
func (el *IQ) InternalServerError() Element
InternalServerError returns an error copy of the element attaching 'internal-server-error' error sub element.
func (*IQ) IsError ¶
func (e *IQ) IsError() bool
IsError returns true if element has a 'type' attribute of value 'error'.
func (*IQ) ItemNotFoundError ¶
func (el *IQ) ItemNotFoundError() Element
ItemNotFoundError returns an error copy of the element attaching 'item-not-found' error sub element.
func (*IQ) JidMalformedError ¶
func (el *IQ) JidMalformedError() Element
JidMalformedError returns an error copy of the element attaching 'jid-malformed' error sub element.
func (*IQ) NotAcceptableError ¶
func (el *IQ) NotAcceptableError() Element
NotAcceptableError returns an error copy of the element attaching 'not-acceptable' error sub element.
func (*IQ) NotAllowedError ¶
func (el *IQ) NotAllowedError() Element
NotAllowedError returns an error copy of the element attaching 'not-allowed' error sub element.
func (*IQ) NotAuthorizedError ¶
func (el *IQ) NotAuthorizedError() Element
NotAuthorizedError returns an error copy of the element attaching 'not-authorized' error sub element.
func (*IQ) PaymentRequiredError ¶
func (el *IQ) PaymentRequiredError() Element
PaymentRequiredError returns an error copy of the element attaching 'payment-required' error sub element.
func (*IQ) RecipientUnavailableError ¶
func (el *IQ) RecipientUnavailableError() Element
RecipientUnavailableError returns an error copy of the element attaching 'recipient-unavailable' error sub element.
func (*IQ) RedirectError ¶
func (el *IQ) RedirectError() Element
RedirectError returns an error copy of the element attaching 'redirect' error sub element.
func (*IQ) RegistrationRequiredError ¶
func (el *IQ) RegistrationRequiredError() Element
RegistrationRequiredError returns an error copy of the element attaching 'registration-required' error sub element.
func (*IQ) RemoteServerNotFoundError ¶
func (el *IQ) RemoteServerNotFoundError() Element
RemoteServerNotFoundError returns an error copy of the element attaching 'remote-server-not-found' error sub element.
func (*IQ) RemoteServerTimeoutError ¶
func (el *IQ) RemoteServerTimeoutError() Element
RemoteServerNotFoundError returns an error copy of the element attaching 'remote-server-timeout' error sub element.
func (*IQ) ResourceConstraintError ¶
func (el *IQ) ResourceConstraintError() Element
ResourceConstraintError returns an error copy of the element attaching 'resource-constraint' error sub element.
func (*IQ) ServiceUnavailableError ¶
func (el *IQ) ServiceUnavailableError() Element
ServiceUnavailableError returns an error copy of the element attaching 'service-unavailable' error sub element.
func (*IQ) SetFromJID ¶
SetFromJID sets the IQ 'from' JID value.
func (*IQ) String ¶
func (e *IQ) String() string
String returns a string representation of the element.
func (*IQ) SubscriptionRequiredError ¶
func (el *IQ) SubscriptionRequiredError() Element
SubscriptionRequiredError returns an error copy of the element attaching 'subscription-required' error sub element.
func (*IQ) Text ¶
func (e *IQ) Text() string
Text returns XML node text value. Returns an empty string if not set.
func (*IQ) ToError ¶
func (el *IQ) ToError(stanzaError *StanzaError) Element
ToError returns an error copy element attaching stanza error sub element.
func (*IQ) ToXML ¶
ToXML serializes element to a raw XML representation. includeClosing determines if closing tag should be attached.
func (*IQ) UndefinedConditionError ¶
func (el *IQ) UndefinedConditionError() Element
UndefinedConditionError returns an error copy of the element attaching 'undefined-condition' error sub element.
func (*IQ) UnexpectedConditionError ¶
func (el *IQ) UnexpectedConditionError() Element
UnexpectedConditionError returns an error copy of the element attaching 'unexpected-condition' error sub element.
type JID ¶
type JID struct {
// contains filtered or unexported fields
}
JID represents an XMPP address (JID). A JID is made up of a node (generally a username), a domain, and a resource. The node and resource are optional; domain is required.
func NewJID ¶
NewJID constructs a JID given a user, domain, and resource. This construction allows the caller to specify if stringprep should be applied or not.
func NewJIDString ¶
NewJIDString constructs a JID from it's string representation. This construction allows the caller to specify if stringprep should be applied or not.
func (*JID) Node ¶
Node returns the node, or empty string if this JID does not contain node information.
func (*JID) Resource ¶
Resource returns the resource, or empty string if this JID does not contain resource information.
type Message ¶
type Message struct { MutableElement // 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 ¶
NewMessageFromElement creates a Message object from Element.
func NewMessageType ¶
NewMessageType creates and returns a new Message element.
func (*Message) Attributes ¶
func (e *Message) Attributes() []Attribute
Attributes returns all XML node attributes.
func (*Message) AttributesCount ¶
func (e *Message) AttributesCount() int
AttributesCount XML attributes count.
func (*Message) BadRequestError ¶
func (el *Message) BadRequestError() Element
BadRequestError returns an error copy of the element attaching 'bad-request' error sub element.
func (*Message) ConflictError ¶
func (el *Message) ConflictError() Element
ConflictError returns an error copy of the element attaching 'conflict' error sub element.
func (*Message) Copy ¶
func (e *Message) Copy() *MutableElement
Copy returns a deep copy of this message stanza.
func (*Message) Elements ¶
func (e *Message) Elements() []Element
Elements returns all instance's child elements.
func (*Message) ElementsCount ¶
func (e *Message) ElementsCount() int
ElementsCount returns child elements count.
func (*Message) FeatureNotImplementedError ¶
func (el *Message) FeatureNotImplementedError() Element
FeatureNotImplementedError returns an error copy of the element attaching 'feature-not-implemented' error sub element.
func (*Message) FindElement ¶
FindElement returns first element identified by name. Returns nil if no element is found.
func (*Message) FindElementNamespace ¶
FindElementNamespace returns first element identified by name and namespace. Returns nil if no element is found.
func (*Message) FindElements ¶
FindElements returns all elements identified by name. Returns an empty array if no elements are found.
func (*Message) FindElementsNamespace ¶
FindElementsNamespace returns all elements identified by name and namespace. Returns an empty array if no elements are found.
func (*Message) ForbiddenError ¶
func (el *Message) ForbiddenError() Element
ForbiddenError returns an error copy of the element attaching 'forbidden' error sub element.
func (*Message) GoneError ¶
func (el *Message) GoneError() Element
GoneError returns an error copy of the element attaching 'gone' error sub element.
func (*Message) InternalServerError ¶
func (el *Message) InternalServerError() Element
InternalServerError returns an error copy of the element attaching 'internal-server-error' error sub element.
func (*Message) IsError ¶
func (e *Message) IsError() bool
IsError returns true if element has a 'type' attribute of value 'error'.
func (*Message) IsGroupChat ¶
IsGroupChat returns true if this is a 'groupchat' type Message.
func (*Message) IsHeadline ¶
IsHeadline returns true if this is a 'headline' type Message.
func (*Message) IsMessageWithBody ¶
IsMessageWithBody returns true if the message has a body sub element.
func (*Message) ItemNotFoundError ¶
func (el *Message) ItemNotFoundError() Element
ItemNotFoundError returns an error copy of the element attaching 'item-not-found' error sub element.
func (*Message) JidMalformedError ¶
func (el *Message) JidMalformedError() Element
JidMalformedError returns an error copy of the element attaching 'jid-malformed' error sub element.
func (*Message) Language ¶
func (e *Message) Language() string
Language returns 'xml:lang' node attribute.
func (*Message) Namespace ¶
func (e *Message) Namespace() string
Namespace returns 'xmlns' node attribute.
func (*Message) NotAcceptableError ¶
func (el *Message) NotAcceptableError() Element
NotAcceptableError returns an error copy of the element attaching 'not-acceptable' error sub element.
func (*Message) NotAllowedError ¶
func (el *Message) NotAllowedError() Element
NotAllowedError returns an error copy of the element attaching 'not-allowed' error sub element.
func (*Message) NotAuthorizedError ¶
func (el *Message) NotAuthorizedError() Element
NotAuthorizedError returns an error copy of the element attaching 'not-authorized' error sub element.
func (*Message) PaymentRequiredError ¶
func (el *Message) PaymentRequiredError() Element
PaymentRequiredError returns an error copy of the element attaching 'payment-required' error sub element.
func (*Message) RecipientUnavailableError ¶
func (el *Message) RecipientUnavailableError() Element
RecipientUnavailableError returns an error copy of the element attaching 'recipient-unavailable' error sub element.
func (*Message) RedirectError ¶
func (el *Message) RedirectError() Element
RedirectError returns an error copy of the element attaching 'redirect' error sub element.
func (*Message) RegistrationRequiredError ¶
func (el *Message) RegistrationRequiredError() Element
RegistrationRequiredError returns an error copy of the element attaching 'registration-required' error sub element.
func (*Message) RemoteServerNotFoundError ¶
func (el *Message) RemoteServerNotFoundError() Element
RemoteServerNotFoundError returns an error copy of the element attaching 'remote-server-not-found' error sub element.
func (*Message) RemoteServerTimeoutError ¶
func (el *Message) RemoteServerTimeoutError() Element
RemoteServerNotFoundError returns an error copy of the element attaching 'remote-server-timeout' error sub element.
func (*Message) ResourceConstraintError ¶
func (el *Message) ResourceConstraintError() Element
ResourceConstraintError returns an error copy of the element attaching 'resource-constraint' error sub element.
func (*Message) ServiceUnavailableError ¶
func (el *Message) ServiceUnavailableError() Element
ServiceUnavailableError returns an error copy of the element attaching 'service-unavailable' error sub element.
func (*Message) SetFromJID ¶
SetFromJID sets the message 'from' JID value.
func (*Message) String ¶
func (e *Message) String() string
String returns a string representation of the element.
func (*Message) SubscriptionRequiredError ¶
func (el *Message) SubscriptionRequiredError() Element
SubscriptionRequiredError returns an error copy of the element attaching 'subscription-required' error sub element.
func (*Message) Text ¶
func (e *Message) Text() string
Text returns XML node text value. Returns an empty string if not set.
func (*Message) TextLen ¶
func (e *Message) TextLen() int
TextLen returns XML node text value length.
func (*Message) ToError ¶
func (el *Message) ToError(stanzaError *StanzaError) Element
ToError returns an error copy element attaching stanza error sub element.
func (*Message) ToXML ¶
ToXML serializes element to a raw XML representation. includeClosing determines if closing tag should be attached.
func (*Message) UndefinedConditionError ¶
func (el *Message) UndefinedConditionError() Element
UndefinedConditionError returns an error copy of the element attaching 'undefined-condition' error sub element.
func (*Message) UnexpectedConditionError ¶
func (el *Message) UnexpectedConditionError() Element
UnexpectedConditionError returns an error copy of the element attaching 'unexpected-condition' error sub element.
type MutableElement ¶
type MutableElement struct {
// contains filtered or unexported fields
}
MutableElement represents a mutable XML node element.
func NewElementFromElement ¶
func NewElementFromElement(elem Element) *MutableElement
NewElementFromElement creates a mutable XML Element by copying an element.
func NewElementName ¶
func NewElementName(name string) *MutableElement
NewElementName creates a mutable XML Element instance with a given name.
func NewElementNamespace ¶
func NewElementNamespace(name, namespace string) *MutableElement
NewElementNamespace creates a mutable XML Element instance with a given name and namespace.
func (*MutableElement) AppendElement ¶
func (m *MutableElement) AppendElement(element Element)
AppendElement appends a new sub element.
func (*MutableElement) AppendElements ¶
func (m *MutableElement) AppendElements(elements []Element)
AppendElements appends an array of sub elements.
func (*MutableElement) Attributes ¶
func (e *MutableElement) Attributes() []Attribute
Attributes returns all XML node attributes.
func (*MutableElement) AttributesCount ¶
func (e *MutableElement) AttributesCount() int
AttributesCount XML attributes count.
func (*MutableElement) BadRequestError ¶
func (el *MutableElement) BadRequestError() Element
BadRequestError returns an error copy of the element attaching 'bad-request' error sub element.
func (*MutableElement) ClearElements ¶
func (m *MutableElement) ClearElements()
ClearElements removes all elements.
func (*MutableElement) ConflictError ¶
func (el *MutableElement) ConflictError() Element
ConflictError returns an error copy of the element attaching 'conflict' error sub element.
func (*MutableElement) Copy ¶
func (e *MutableElement) Copy() *MutableElement
Copy returns a deep copy of this message stanza.
func (*MutableElement) Delay ¶
func (m *MutableElement) Delay(from string, text string)
Delay attaches element's Delayed Delivery information.
func (*MutableElement) Elements ¶
func (e *MutableElement) Elements() []Element
Elements returns all instance's child elements.
func (*MutableElement) ElementsCount ¶
func (e *MutableElement) ElementsCount() int
ElementsCount returns child elements count.
func (*MutableElement) Error ¶
func (e *MutableElement) Error() Element
Error returns element error sub element.
func (*MutableElement) FeatureNotImplementedError ¶
func (el *MutableElement) FeatureNotImplementedError() Element
FeatureNotImplementedError returns an error copy of the element attaching 'feature-not-implemented' error sub element.
func (*MutableElement) FindElement ¶
FindElement returns first element identified by name. Returns nil if no element is found.
func (*MutableElement) FindElementNamespace ¶
FindElementNamespace returns first element identified by name and namespace. Returns nil if no element is found.
func (*MutableElement) FindElements ¶
FindElements returns all elements identified by name. Returns an empty array if no elements are found.
func (*MutableElement) FindElementsNamespace ¶
FindElementsNamespace returns all elements identified by name and namespace. Returns an empty array if no elements are found.
func (*MutableElement) ForbiddenError ¶
func (el *MutableElement) ForbiddenError() Element
ForbiddenError returns an error copy of the element attaching 'forbidden' error sub element.
func (*MutableElement) From ¶
func (e *MutableElement) From() string
From returns 'from' node attribute.
func (*MutableElement) FromBytes ¶
FromBytes deserializes XML element from it's gob binary representation.
func (*MutableElement) GoneError ¶
func (el *MutableElement) GoneError() Element
GoneError returns an error copy of the element attaching 'gone' error sub element.
func (*MutableElement) InternalServerError ¶
func (el *MutableElement) InternalServerError() Element
InternalServerError returns an error copy of the element attaching 'internal-server-error' error sub element.
func (*MutableElement) IsError ¶
func (e *MutableElement) IsError() bool
IsError returns true if element has a 'type' attribute of value 'error'.
func (*MutableElement) ItemNotFoundError ¶
func (el *MutableElement) ItemNotFoundError() Element
ItemNotFoundError returns an error copy of the element attaching 'item-not-found' error sub element.
func (*MutableElement) JidMalformedError ¶
func (el *MutableElement) JidMalformedError() Element
JidMalformedError returns an error copy of the element attaching 'jid-malformed' error sub element.
func (*MutableElement) Language ¶
func (e *MutableElement) Language() string
Language returns 'xml:lang' node attribute.
func (*MutableElement) Namespace ¶
func (e *MutableElement) Namespace() string
Namespace returns 'xmlns' node attribute.
func (*MutableElement) NotAcceptableError ¶
func (el *MutableElement) NotAcceptableError() Element
NotAcceptableError returns an error copy of the element attaching 'not-acceptable' error sub element.
func (*MutableElement) NotAllowedError ¶
func (el *MutableElement) NotAllowedError() Element
NotAllowedError returns an error copy of the element attaching 'not-allowed' error sub element.
func (*MutableElement) NotAuthorizedError ¶
func (el *MutableElement) NotAuthorizedError() Element
NotAuthorizedError returns an error copy of the element attaching 'not-authorized' error sub element.
func (*MutableElement) PaymentRequiredError ¶
func (el *MutableElement) PaymentRequiredError() Element
PaymentRequiredError returns an error copy of the element attaching 'payment-required' error sub element.
func (*MutableElement) RecipientUnavailableError ¶
func (el *MutableElement) RecipientUnavailableError() Element
RecipientUnavailableError returns an error copy of the element attaching 'recipient-unavailable' error sub element.
func (*MutableElement) RedirectError ¶
func (el *MutableElement) RedirectError() Element
RedirectError returns an error copy of the element attaching 'redirect' error sub element.
func (*MutableElement) RegistrationRequiredError ¶
func (el *MutableElement) RegistrationRequiredError() Element
RegistrationRequiredError returns an error copy of the element attaching 'registration-required' error sub element.
func (*MutableElement) RemoteServerNotFoundError ¶
func (el *MutableElement) RemoteServerNotFoundError() Element
RemoteServerNotFoundError returns an error copy of the element attaching 'remote-server-not-found' error sub element.
func (*MutableElement) RemoteServerTimeoutError ¶
func (el *MutableElement) RemoteServerTimeoutError() Element
RemoteServerNotFoundError returns an error copy of the element attaching 'remote-server-timeout' error sub element.
func (*MutableElement) RemoveAttribute ¶
func (m *MutableElement) RemoveAttribute(label string)
RemoveAttribute removes an XML node attribute.
func (*MutableElement) RemoveElements ¶
func (m *MutableElement) RemoveElements(name string)
RemoveElements removes all elements with a given name.
func (*MutableElement) RemoveElementsNamespace ¶
func (m *MutableElement) RemoveElementsNamespace(name, namespace string)
RemoveElementsNamespace removes all elements with a given name and namespace.
func (*MutableElement) ResourceConstraintError ¶
func (el *MutableElement) ResourceConstraintError() Element
ResourceConstraintError returns an error copy of the element attaching 'resource-constraint' error sub element.
func (*MutableElement) ServiceUnavailableError ¶
func (el *MutableElement) ServiceUnavailableError() Element
ServiceUnavailableError returns an error copy of the element attaching 'service-unavailable' error sub element.
func (*MutableElement) SetAttribute ¶
func (m *MutableElement) SetAttribute(label, value string)
SetAttribute sets an XML node attribute (label=value)
func (*MutableElement) SetFrom ¶
func (m *MutableElement) SetFrom(from string)
SetFrom sets 'from' node attribute.
func (*MutableElement) SetID ¶
func (m *MutableElement) SetID(identifier string)
SetID sets 'id' node attribute.
func (*MutableElement) SetLanguage ¶
func (m *MutableElement) SetLanguage(language string)
SetLanguage sets 'xml:lang' node attribute.
func (*MutableElement) SetName ¶
func (m *MutableElement) SetName(name string)
SetName sets XML node name.
func (*MutableElement) SetNamespace ¶
func (m *MutableElement) SetNamespace(namespace string)
SetNamespace sets 'xmlns' node attribute.
func (*MutableElement) SetText ¶
func (m *MutableElement) SetText(text string)
SetText sets XML node text value.
func (*MutableElement) SetTo ¶
func (m *MutableElement) SetTo(to string)
SetTo sets 'to' node attribute.
func (*MutableElement) SetType ¶
func (m *MutableElement) SetType(tp string)
SetType sets 'type' node attribute.
func (*MutableElement) SetVersion ¶
func (m *MutableElement) SetVersion(version string)
SetVersion sets 'version' node attribute.
func (*MutableElement) String ¶
func (e *MutableElement) String() string
String returns a string representation of the element.
func (*MutableElement) SubscriptionRequiredError ¶
func (el *MutableElement) SubscriptionRequiredError() Element
SubscriptionRequiredError returns an error copy of the element attaching 'subscription-required' error sub element.
func (*MutableElement) Text ¶
func (e *MutableElement) Text() string
Text returns XML node text value. Returns an empty string if not set.
func (*MutableElement) TextLen ¶
func (e *MutableElement) TextLen() int
TextLen returns XML node text value length.
func (*MutableElement) ToError ¶
func (el *MutableElement) ToError(stanzaError *StanzaError) Element
ToError returns an error copy element attaching stanza error sub element.
func (*MutableElement) ToXML ¶
ToXML serializes element to a raw XML representation. includeClosing determines if closing tag should be attached.
func (*MutableElement) Type ¶
func (e *MutableElement) Type() string
Type returns 'type' node attribute.
func (*MutableElement) UndefinedConditionError ¶
func (el *MutableElement) UndefinedConditionError() Element
UndefinedConditionError returns an error copy of the element attaching 'undefined-condition' error sub element.
func (*MutableElement) UnexpectedConditionError ¶
func (el *MutableElement) UnexpectedConditionError() Element
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 (*Parser) ParseElement ¶
ParseElement parses next available XML element from reader.
type Presence ¶
type Presence struct { MutableElement // 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 ¶
NewPresence creates and returns a new Presence element.
func NewPresenceFromElement ¶
NewPresenceFromElement creates a Presence object from Element.
func (*Presence) Attributes ¶
func (e *Presence) Attributes() []Attribute
Attributes returns all XML node attributes.
func (*Presence) AttributesCount ¶
func (e *Presence) AttributesCount() int
AttributesCount XML attributes count.
func (*Presence) BadRequestError ¶
func (el *Presence) BadRequestError() Element
BadRequestError returns an error copy of the element attaching 'bad-request' error sub element.
func (*Presence) ConflictError ¶
func (el *Presence) ConflictError() Element
ConflictError returns an error copy of the element attaching 'conflict' error sub element.
func (*Presence) Copy ¶
func (e *Presence) Copy() *MutableElement
Copy returns a deep copy of this message stanza.
func (*Presence) Elements ¶
func (e *Presence) Elements() []Element
Elements returns all instance's child elements.
func (*Presence) ElementsCount ¶
func (e *Presence) ElementsCount() int
ElementsCount returns child elements count.
func (*Presence) Error ¶
func (e *Presence) Error() Element
Error returns element error sub element.
func (*Presence) FeatureNotImplementedError ¶
func (el *Presence) FeatureNotImplementedError() Element
FeatureNotImplementedError returns an error copy of the element attaching 'feature-not-implemented' error sub element.
func (*Presence) FindElement ¶
FindElement returns first element identified by name. Returns nil if no element is found.
func (*Presence) FindElementNamespace ¶
FindElementNamespace returns first element identified by name and namespace. Returns nil if no element is found.
func (*Presence) FindElements ¶
FindElements returns all elements identified by name. Returns an empty array if no elements are found.
func (*Presence) FindElementsNamespace ¶
FindElementsNamespace returns all elements identified by name and namespace. Returns an empty array if no elements are found.
func (*Presence) ForbiddenError ¶
func (el *Presence) ForbiddenError() Element
ForbiddenError returns an error copy of the element attaching 'forbidden' error sub element.
func (*Presence) FromBytes ¶
FromBytes deserializes XML element from it's gob binary representation.
func (*Presence) GoneError ¶
func (el *Presence) GoneError() Element
GoneError returns an error copy of the element attaching 'gone' error sub element.
func (*Presence) InternalServerError ¶
func (el *Presence) InternalServerError() Element
InternalServerError returns an error copy of the element attaching 'internal-server-error' error sub element.
func (*Presence) IsAvailable ¶
IsAvailable returns true if this is an 'available' type Presence.
func (*Presence) IsError ¶
func (e *Presence) IsError() bool
IsError returns true if element has a 'type' attribute of value 'error'.
func (*Presence) IsSubscribe ¶
IsSubscribe returns true if this is a 'subscribe' type Presence.
func (*Presence) IsSubscribed ¶
IsSubscribed returns true if this is a 'subscribed' type Presence.
func (*Presence) IsUnavailable ¶
IsUnavailable returns true if this is an 'unavailable' type Presence.
func (*Presence) IsUnsubscribe ¶
IsUnsubscribe returns true if this is an 'unsubscribe' type Presence.
func (*Presence) IsUnsubscribed ¶
IsUnsubscribed returns true if this is an 'unsubscribed' type Presence.
func (*Presence) ItemNotFoundError ¶
func (el *Presence) ItemNotFoundError() Element
ItemNotFoundError returns an error copy of the element attaching 'item-not-found' error sub element.
func (*Presence) JidMalformedError ¶
func (el *Presence) JidMalformedError() Element
JidMalformedError returns an error copy of the element attaching 'jid-malformed' error sub element.
func (*Presence) Language ¶
func (e *Presence) Language() string
Language returns 'xml:lang' node attribute.
func (*Presence) Namespace ¶
func (e *Presence) Namespace() string
Namespace returns 'xmlns' node attribute.
func (*Presence) NotAcceptableError ¶
func (el *Presence) NotAcceptableError() Element
NotAcceptableError returns an error copy of the element attaching 'not-acceptable' error sub element.
func (*Presence) NotAllowedError ¶
func (el *Presence) NotAllowedError() Element
NotAllowedError returns an error copy of the element attaching 'not-allowed' error sub element.
func (*Presence) NotAuthorizedError ¶
func (el *Presence) NotAuthorizedError() Element
NotAuthorizedError returns an error copy of the element attaching 'not-authorized' error sub element.
func (*Presence) PaymentRequiredError ¶
func (el *Presence) PaymentRequiredError() Element
PaymentRequiredError returns an error copy of the element attaching 'payment-required' error sub element.
func (*Presence) RecipientUnavailableError ¶
func (el *Presence) RecipientUnavailableError() Element
RecipientUnavailableError returns an error copy of the element attaching 'recipient-unavailable' error sub element.
func (*Presence) RedirectError ¶
func (el *Presence) RedirectError() Element
RedirectError returns an error copy of the element attaching 'redirect' error sub element.
func (*Presence) RegistrationRequiredError ¶
func (el *Presence) RegistrationRequiredError() Element
RegistrationRequiredError returns an error copy of the element attaching 'registration-required' error sub element.
func (*Presence) RemoteServerNotFoundError ¶
func (el *Presence) RemoteServerNotFoundError() Element
RemoteServerNotFoundError returns an error copy of the element attaching 'remote-server-not-found' error sub element.
func (*Presence) RemoteServerTimeoutError ¶
func (el *Presence) RemoteServerTimeoutError() Element
RemoteServerNotFoundError returns an error copy of the element attaching 'remote-server-timeout' error sub element.
func (*Presence) ResourceConstraintError ¶
func (el *Presence) ResourceConstraintError() Element
ResourceConstraintError returns an error copy of the element attaching 'resource-constraint' error sub element.
func (*Presence) ServiceUnavailableError ¶
func (el *Presence) ServiceUnavailableError() Element
ServiceUnavailableError returns an error copy of the element attaching 'service-unavailable' error sub element.
func (*Presence) SetFromJID ¶
SetFromJID sets the presence 'from' JID value.
func (*Presence) String ¶
func (e *Presence) String() string
String returns a string representation of the element.
func (*Presence) SubscriptionRequiredError ¶
func (el *Presence) SubscriptionRequiredError() Element
SubscriptionRequiredError returns an error copy of the element attaching 'subscription-required' error sub element.
func (*Presence) Text ¶
func (e *Presence) Text() string
Text returns XML node text value. Returns an empty string if not set.
func (*Presence) TextLen ¶
func (e *Presence) TextLen() int
TextLen returns XML node text value length.
func (*Presence) ToError ¶
func (el *Presence) ToError(stanzaError *StanzaError) Element
ToError returns an error copy element attaching stanza error sub element.
func (*Presence) ToXML ¶
ToXML serializes element to a raw XML representation. includeClosing determines if closing tag should be attached.
func (*Presence) UndefinedConditionError ¶
func (el *Presence) UndefinedConditionError() Element
UndefinedConditionError returns an error copy of the element attaching 'undefined-condition' error sub element.
func (*Presence) UnexpectedConditionError ¶
func (el *Presence) UnexpectedConditionError() Element
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 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.