Documentation ¶
Index ¶
- Constants
- Variables
- type Attribute
- type AttributeReader
- type Builder
- func (b *Builder) Build() Element
- func (b *Builder) BuildIQ(validateJIDs bool) (*IQ, error)
- func (b *Builder) BuildMessage(validateJIDs bool) (*Message, error)
- func (b *Builder) BuildPresence(validateJIDs bool) (*Presence, error)
- func (b *Builder) BuildStanza(validateJIDs bool) (Stanza, error)
- func (b *Builder) WithAttribute(label, value string) *Builder
- func (b *Builder) WithAttributes(attributes ...Attribute) *Builder
- func (b *Builder) WithChild(child Element) *Builder
- func (b *Builder) WithChildren(children ...Element) *Builder
- func (b *Builder) WithName(name string) *Builder
- func (b *Builder) WithText(text string) *Builder
- func (b *Builder) WithoutAttribute(label string) *Builder
- func (b *Builder) WithoutChildren(name string) *Builder
- func (b *Builder) WithoutChildrenNamespace(name, ns string) *Builder
- type Capabilities
- type Element
- type ElementReader
- type IQ
- func (s *IQ) Error() Element
- func (s *IQ) FromJID() *jid.JID
- func (s *IQ) ID() string
- func (s *IQ) IsError() bool
- func (iq *IQ) IsGet() bool
- func (iq *IQ) IsResult() bool
- func (iq *IQ) IsSet() bool
- func (s *IQ) Namespace() string
- func (iq *IQ) ResultIQ() *IQ
- func (s *IQ) ToJID() *jid.JID
- func (s *IQ) Type() string
- type Message
- func (s *Message) Error() Element
- func (s *Message) FromJID() *jid.JID
- func (s *Message) ID() string
- func (m *Message) IsChat() bool
- func (s *Message) IsError() bool
- func (m *Message) IsGroupChat() bool
- func (m *Message) IsHeadline() bool
- func (m *Message) IsMessageWithBody() bool
- func (m *Message) IsNormal() bool
- func (s *Message) Namespace() string
- func (s *Message) ToJID() *jid.JID
- func (s *Message) Type() string
- type PBAttribute
- type PBElement
- func (*PBElement) Descriptor() ([]byte, []int)deprecated
- func (x *PBElement) GetAttributes() []*PBAttribute
- func (x *PBElement) GetElements() []*PBElement
- func (x *PBElement) GetName() string
- func (x *PBElement) GetText() string
- func (*PBElement) ProtoMessage()
- func (x *PBElement) ProtoReflect() protoreflect.Message
- func (x *PBElement) Reset()
- func (x *PBElement) String() string
- type Presence
- func (p *Presence) Capabilities() *Capabilities
- func (s *Presence) Error() Element
- func (s *Presence) FromJID() *jid.JID
- func (s *Presence) ID() string
- func (p *Presence) IsAvailable() bool
- func (s *Presence) IsError() bool
- func (p *Presence) IsProbe() 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 (s *Presence) Namespace() string
- func (p *Presence) Priority() int8
- func (p *Presence) ShowState() ShowState
- func (p *Presence) Status() string
- func (s *Presence) ToJID() *jid.JID
- func (s *Presence) Type() string
- type ShowState
- type Stanza
- func BadRequestError(stanza Stanza) Stanza
- func ConflictError(stanza Stanza) Stanza
- func FeatureNotImplementedError(stanza Stanza) Stanza
- func ForbiddenError(stanza Stanza) Stanza
- func GoneError(stanza Stanza) Stanza
- func InternalServerError(stanza Stanza) Stanza
- func ItemNotFoundError(stanza Stanza) Stanza
- func JidMalformedError(stanza Stanza) Stanza
- func NotAcceptableError(stanza Stanza) Stanza
- func NotAllowedError(stanza Stanza) Stanza
- func NotAuthorizedError(stanza Stanza) Stanza
- func PaymentRequiredError(stanza Stanza) Stanza
- func RecipientUnavailableError(stanza Stanza) Stanza
- func RedirectError(stanza Stanza) Stanza
- func RegistrationRequiredError(stanza Stanza) Stanza
- func RemoteServerNotFoundError(stanza Stanza) Stanza
- func RemoteServerTimeoutError(stanza Stanza) Stanza
- func ResourceConstraintError(stanza Stanza) Stanza
- func ServiceUnavailableError(stanza Stanza) Stanza
- func SubscriptionRequiredError(stanza Stanza) Stanza
- func ToStanzaError(stanza Stanza, stanzaError *StanzaError, errorElements []Element) Stanza
- func UndefinedConditionError(stanza Stanza) Stanza
- func UnexpectedConditionError(stanza Stanza) Stanza
- func UnexpectedRequestError(stanza Stanza) Stanza
- type StanzaError
- type XMLSerializer
Constants ¶
const ( // ID represents 'id' node attribute. ID = "id" // Language represents 'xml:lang' node attribute. Language = "xml:lang" // From represents 'from' node attribute. From = "from" // To represents 'to' node attribute. To = "to" // Type represents 'type' node attribute. Type = "type" // Version represents 'version' node attribute. Version = "version" // Namespace represents 'xmlns' node attribute. Namespace = "xmlns" )
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 = "" 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" )
const (
// ErrorType represents a generic 'error' type stanza.
ErrorType = "error"
)
Variables ¶
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) // 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) // 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) )
var File_stravaganza_proto protoreflect.FileDescriptor
Functions ¶
This section is empty.
Types ¶
type AttributeReader ¶
type AttributeReader interface { // AllChildren returns a list of all node attributes. AllAttributes() []Attribute // AttributeCount returns node total attribute count. AttributeCount() int // Attribute returns XML node attribute value. Attribute(label string) Attribute }
AttributeReader defines an XML attributes read-only interface.
type Builder ¶
type Builder struct {
// contains filtered or unexported fields
}
Builder builds generic XML node elements.
func NewBuilder ¶
NewBuilder returns a name initialized builder instance.
func NewBuilderFromBinary ¶
NewBuilderFromBinary returns an element builder derived from an element binary representation.
func NewBuilderFromElement ¶
NewBuilderFromElement returns an element builder derived from a copied element.
func NewIQBuilder ¶ added in v0.6.0
func NewIQBuilder() *Builder
NewPresenceBuilder returns an 'iq' stanza builder instance.
func NewMessageBuilder ¶ added in v0.6.0
func NewMessageBuilder() *Builder
NewMessageBuilder returns a 'message' stanza builder instance.
func NewPresenceBuilder ¶ added in v0.6.0
func NewPresenceBuilder() *Builder
NewPresenceBuilder returns a 'presence' stanza builder instance.
func (*Builder) BuildMessage ¶
BuildMessage validates and returns a new Message stanza.
func (*Builder) BuildPresence ¶
BuildPresence validates and returns a new Presence stanza.
func (*Builder) BuildStanza ¶
BuildStanza validates and returns a generic stanza instance.
func (*Builder) WithAttribute ¶
WithAttribute sets an XML node attribute (label=value).
func (*Builder) WithAttributes ¶
WithAttributes sets all XML node attributes.
func (*Builder) WithChildren ¶
WithChildren appends all new sub elements.
func (*Builder) WithoutAttribute ¶
WithoutAttribute removes an XML node attribute.
func (*Builder) WithoutChildren ¶
WithoutChildren removes all elements with a given name.
func (*Builder) WithoutChildrenNamespace ¶
WithoutChildrenNamespace removes all elements with a given name and namespace.
type Capabilities ¶
Capabilities represents presence entity capabilities
type Element ¶
type Element interface { AttributeReader ElementReader XMLSerializer encoding.BinaryMarshaler fmt.Stringer fmt.GoStringer // Name returns XML node name. Name() string // Text returns XML node text value. Text() string // Proto returns element protobuf message. Proto() *PBElement }
Element represents a generic XML node element.
type ElementReader ¶
type ElementReader interface { // AllChildren returns a list of all child nodes. AllChildren() []Element // ChildrenCount returns child elements count. ChildrenCount() int // Child returns first element identified by name. Child(name string) Element // Children returns all elements identified by name. // Returns an empty array if no elements are found. Children(name string) []Element // ChildNamespace returns first element identified by name and namespace. // Returns nil if no element is found. ChildNamespace(name, ns string) Element // ChildrenNamespace returns all elements identified by name and namespace. ChildrenNamespace(name, ns string) []Element }
ElementReader defines an XML sub elements read-only interface.
type IQ ¶
type IQ struct {
// contains filtered or unexported fields
}
IQ type represents an <iq> element.
type Message ¶
type Message struct {
// contains filtered or unexported fields
}
Message type represents a <message> element.
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.
type PBAttribute ¶ added in v0.7.0
type PBAttribute struct { Label string `protobuf:"bytes,1,opt,name=label,proto3" json:"label,omitempty"` Value string `protobuf:"bytes,2,opt,name=value,proto3" json:"value,omitempty"` // contains filtered or unexported fields }
func (*PBAttribute) Descriptor
deprecated
added in
v0.7.0
func (*PBAttribute) Descriptor() ([]byte, []int)
Deprecated: Use PBAttribute.ProtoReflect.Descriptor instead.
func (*PBAttribute) GetLabel ¶ added in v0.7.0
func (x *PBAttribute) GetLabel() string
func (*PBAttribute) GetValue ¶ added in v0.7.0
func (x *PBAttribute) GetValue() string
func (*PBAttribute) ProtoMessage ¶ added in v0.7.0
func (*PBAttribute) ProtoMessage()
func (*PBAttribute) ProtoReflect ¶ added in v0.7.0
func (x *PBAttribute) ProtoReflect() protoreflect.Message
func (*PBAttribute) Reset ¶ added in v0.7.0
func (x *PBAttribute) Reset()
func (*PBAttribute) String ¶ added in v0.7.0
func (x *PBAttribute) String() string
type PBElement ¶ added in v0.7.0
type PBElement struct { Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` Attributes []*PBAttribute `protobuf:"bytes,2,rep,name=attributes,proto3" json:"attributes,omitempty"` Elements []*PBElement `protobuf:"bytes,3,rep,name=elements,proto3" json:"elements,omitempty"` Text string `protobuf:"bytes,4,opt,name=text,proto3" json:"text,omitempty"` // contains filtered or unexported fields }
func (*PBElement) Descriptor
deprecated
added in
v0.7.0
func (*PBElement) GetAttributes ¶ added in v0.7.0
func (x *PBElement) GetAttributes() []*PBAttribute
func (*PBElement) GetElements ¶ added in v0.7.0
func (*PBElement) ProtoMessage ¶ added in v0.7.0
func (*PBElement) ProtoMessage()
func (*PBElement) ProtoReflect ¶ added in v0.7.0
func (x *PBElement) ProtoReflect() protoreflect.Message
type Presence ¶
type Presence struct {
// contains filtered or unexported fields
}
Presence type represents a <presence> element.
func (*Presence) Capabilities ¶
func (p *Presence) Capabilities() *Capabilities
Capabilities returns presence stanza capabilities element
func (*Presence) IsAvailable ¶
IsAvailable returns true if this is an 'available' type Presence.
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.
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 { Element // ToJID returns stanza 'to' JID value. ToJID() *jid.JID // FromJID returns stanza 'from' JID value. FromJID() *jid.JID // ID returns 'id' node attribute. ID() string // Namespace returns 'xmlns' node attribute. Namespace() string // Type returns 'type' node attribute. Type() string // IsError returns true if stanza has a 'type' attribute of value 'error'. IsError() bool // Error returns stanza error sub element. Error() Element }
Stanza represents an XMPP stanza element.
func BadRequestError ¶
BadRequestError returns an error copy of the element attaching 'bad-request' error sub element.
func ConflictError ¶
ConflictError returns an error copy of the element attaching 'conflict' error sub element.
func FeatureNotImplementedError ¶
FeatureNotImplementedError returns an error copy of the element attaching 'feature-not-implemented' error sub element.
func ForbiddenError ¶
ForbiddenError returns an error copy of the element attaching 'forbidden' error sub element.
func InternalServerError ¶
InternalServerError returns an error copy of the element attaching 'internal-server-error' error sub element.
func ItemNotFoundError ¶
ItemNotFoundError returns an error copy of the element attaching 'item-not-found' error sub element.
func JidMalformedError ¶
JidMalformedError returns an error copy of the element attaching 'jid-malformed' error sub element.
func NotAcceptableError ¶
NotAcceptableError returns an error copy of the element attaching 'not-acceptable' error sub element.
func NotAllowedError ¶
NotAllowedError returns an error copy of the element attaching 'not-allowed' error sub element.
func NotAuthorizedError ¶
NotAuthorizedError returns an error copy of the element attaching 'not-authorized' error sub element.
func PaymentRequiredError ¶
PaymentRequiredError returns an error copy of the element attaching 'payment-required' error sub element.
func RecipientUnavailableError ¶
RecipientUnavailableError returns an error copy of the element attaching 'recipient-unavailable' error sub element.
func RedirectError ¶
RedirectError returns an error copy of the element attaching 'redirect' error sub element.
func RegistrationRequiredError ¶
RegistrationRequiredError returns an error copy of the element attaching 'registration-required' error sub element.
func RemoteServerNotFoundError ¶
RemoteServerNotFoundError returns an error copy of the element attaching 'remote-server-not-found' error sub element.
func RemoteServerTimeoutError ¶
RemoteServerTimeoutError returns an error copy of the element attaching 'remote-server-timeout' error sub element.
func ResourceConstraintError ¶
ResourceConstraintError returns an error copy of the element attaching 'resource-constraint' error sub element.
func ServiceUnavailableError ¶
ServiceUnavailableError returns an error copy of the element attaching 'service-unavailable' error sub element.
func SubscriptionRequiredError ¶
SubscriptionRequiredError returns an error copy of the element attaching 'subscription-required' error sub element.
func ToStanzaError ¶
func ToStanzaError(stanza Stanza, stanzaError *StanzaError, errorElements []Element) Stanza
ToStanzaError returns the derived equivalent error stanza.
func UndefinedConditionError ¶
UndefinedConditionError returns an error copy of the element attaching 'undefined-condition' error sub element.
func UnexpectedConditionError ¶
UnexpectedConditionError returns an error copy of the element attaching 'unexpected-condition' error sub element.
func UnexpectedRequestError ¶
UnexpectedRequestError returns an error copy of the element attaching 'unexpected-request' error sub element.
type StanzaError ¶
type StanzaError struct {
// contains filtered or unexported fields
}
StanzaError represents a stanza "error" element.
func (*StanzaError) ToElement ¶
func (se *StanzaError) ToElement(errElements []Element) Element
ToElement returns StanzaError equivalent XML element.