Documentation ¶
Index ¶
- Constants
- Variables
- func IsStanza(el Element) bool
- type Attribute
- type AttributeReader
- type Builder
- func (b *Builder) Build() Element
- func (b *Builder) BuildIQ() (*IQ, error)
- func (b *Builder) BuildMessage() (*Message, error)
- func (b *Builder) BuildPresence() (*Presence, error)
- func (b *Builder) BuildStanza() (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) WithValidateJIDs(validateJIDs bool) *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) ResultBuilder() *Builder
- 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
- 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" // StreamNamespace represents 'xmlns:stream' node attribute. StreamNamespace = "xmlns:stream" )
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"
)
const IQName = "iq"
IQName represents 'iq' stanza type name.
const MessageName = "message"
MessageName represents 'message' stanza type name.
const PresenceName = "presence"
PresenceName represents 'presence' stanza type name.
Variables ¶
var File_stravaganza_proto protoreflect.FileDescriptor
Functions ¶
Types ¶
type AttributeReader ¶
type AttributeReader interface { // AllAttributes 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) string }
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 NewBuilderFromProto ¶ added in v0.9.0
NewBuilderFromProto returns an element builder derived from proto type.
func NewIQBuilder ¶ added in v0.6.0
func NewIQBuilder() *Builder
NewIQBuilder 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) WithValidateJIDs ¶ added in v1.1.1
WithValidateJIDs sets validate JIDs value.
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 encoding.BinaryUnmarshaler 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.
func EmptyElement ¶ added in v1.1.1
func EmptyElement() Element
EmptyElement returns an empty element instace. Useful in case you want to deserialize an element using encoding.UnmarshalBinary interface.
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.
func (*IQ) ResultBuilder ¶ added in v0.18.1
ResultBuilder returns a builder instance associated to iq result stanza.
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.