Documentation ¶
Index ¶
- Constants
- func AlwaysOnlinePresenceHandler(c *Component, p *Presence) error
- type Address
- type Component
- type DiscoFeature
- type DiscoIdentity
- type DiscoInfoHandler
- type DiscoInfoQuery
- type Error
- type Header
- type Iq
- type IqHandler
- type Message
- type MessageHandler
- type MessageType
- type Options
- type Presence
- type PresenceHandler
- type ReceiptAck
- type Sender
- type UnknownElementHandler
- type Vcard
Constants ¶
const ( // CHAT defines the chat message type CHAT = MessageType("chat") // ERROR defines the error message type ERROR = MessageType("error") // GROUPCHAT defines the group chat message type GROUPCHAT = MessageType("groupchat") // HEADLINE defines the headline message type HEADLINE = MessageType("headline") // NORMAL defines the normal message type NORMAL = MessageType("normal") )
const ( // SUBSCRIBE represents the subscribe Presence message type SUBSCRIBE = "subscribe" // SUBSCRIBED represents the subscribed Presence message type SUBSCRIBED = "subscribed" // UNSUBSCRIBE represents the unsubsribe Presence message type UNSUBSCRIBE = "unsubscribe" // UNSUBSCRIBED represents the unsubsribed Presence message type UNSUBSCRIBED = "unsubscribed" // UNAVAILABLE represents the unavailable Presence message type UNAVAILABLE = "unavailable" // PROBE represents the probe Presence message type PROBE = "probe" )
Variables ¶
This section is empty.
Functions ¶
func AlwaysOnlinePresenceHandler ¶
AlwaysOnlinePresenceHandler always returns "subscribed" to any presence requests
Types ¶
type Address ¶
Address is an XMPP JID address
func ParseAddress ¶
ParseAddress parses the address from the given string
func (*Address) MarshalXMLAttr ¶
MarshalXMLAttr marks the Address struct as being able to be written as an XML attribute
type Component ¶
type Component struct { MessageHandler MessageHandler DiscoInfoHandler DiscoInfoHandler PresenceHandler PresenceHandler IqHandler IqHandler UnknownHandler UnknownElementHandler // contains filtered or unexported fields }
A Component is an instance of a Jabber Component (XEP-0114)
func NewComponent ¶
NewComponent creates a new component from the given options
type DiscoFeature ¶
type DiscoFeature struct { // Var is a mandatory protocol namespace offered by the entity. Var string `xml:"var,attr"` XMLName string `xml:"feature"` }
DiscoFeature represents a feature element in a response to a service discovery info query.
See the registry of features at http://xmpp.org/registrar/disco-features.html
type DiscoIdentity ¶
type DiscoIdentity struct { // Category is a mandatory description of the category of this // identity. Category often contains values like "conference", // "directory", "gateway", "server", "client", etc. // // See the category registry at http://xmpp.org/registrar/disco-categories.html Category string `xml:"category,attr"` // Type is a mandatory description of the type of this identity. // The type goes together with the Category to help requesting // entities know which services are offered. // // For example, if Category is "gateway" then Type might be "msn" // or "aim". See the type registry at http://xmpp.org/registrar/disco-categories.html Type string `xml:"type,attr"` // Name is an optional natural language name for the entity // described by this identity. Name string `xml:"name,attr,omitempty"` XMLName string `xml:"identity"` }
DiscoIdentity represents an identity element in a response to a service discovery info query.
type DiscoInfoHandler ¶
type DiscoInfoHandler func(c *Component, iq *Iq) ([]DiscoIdentity, []DiscoFeature, error)
DiscoInfoHandler handles an incoming service discovery request. The target entity is described by iq.To. This function's first return value is a slice of identities for the target entity. The second is a slice of features offered by the target entity.
You don't have to include a feature indicating support for service discovery, one is automatically added for you. If you return 0 identity elements, service discovery is disabled.
type DiscoInfoQuery ¶
type DiscoInfoQuery struct { Identities []DiscoIdentity Features []DiscoFeature XMLName xml.Name `xml:"http://jabber.org/protocol/disco#info query"` }
DiscoInfoQuery represents a service discovery info query message. See section 3.1 in XEP-0030.
type Error ¶
type Error struct { XMLName xml.Name Code string `xml:"code,omitempty,attr"` Type string `xml:"type,omitempty,attr"` }
Error is the error sent over XMPP
type Header ¶
type Header struct { ID string `xml:"id,attr,omitempty"` From *Address `xml:"from,attr,omitempty"` To *Address `xml:"to,attr,omitempty"` }
Header contains the common fields for every XEP-0114 message
type Iq ¶
type Iq struct { Header Type string `xml:"type,attr"` Content string `xml:",innerxml"` Vcard *Vcard `xml:"vcard-temp vCard,omitempty"` XMLName string `xml:"iq"` }
Iq represents an info/query message
func (*Iq) IsDiscoInfo ¶
IsDiscoInfo returns true if an iq stanza is a service discovery info query.
type Message ¶
type Message struct { Header Type MessageType `xml:"type,attr,omitempty"` Subject string `xml:"subject,omitempty"` Body string `xml:"body,omitempty"` Error *Error `xml:"error"` Thread string `xml:"thread,omitempty"` Content string `xml:",innerxml"` // allow arbitrary content // XEP-0184 message delivery receipts ReceiptRequest *xml.Name `xml:"urn:xmpp:receipts request,omitempty"` ReceiptAck *ReceiptAck `xml:"urn:xmpp:receipts received,omitempty"` // XEP-0172 User nicknames Nick string `xml:"http://jabber.org/protocol/nick nick,omitempty"` XMLName xml.Name `xml:"message"` }
A Message is an incoming or outgoing Component message
type MessageHandler ¶
A MessageHandler handles an incoming message
func BodyResponseHandler ¶
func BodyResponseHandler(fn func(*Message) (string, error)) MessageHandler
BodyResponseHandler builds a simple request-response style function which returns the body of the response message
type MessageType ¶
type MessageType string
MessageType defines the constants for the types of messages within XEP-0114
type Options ¶
type Options struct { // Name defines the component name Name string SharedSecret string // Address is the address of the XMPP server Address string // The (optional) parent context Context context.Context // Logger is an optional logger to which to send raw XML stanzas // sent and received. It's primarily intended for debugging and // development. Logger *log.Logger }
Options define the series of options required to build a component
type Presence ¶
type Presence struct { Header Show string `xml:"show,omitempty"` Status string `xml:"status,omitempty"` Priority byte `xml:"priority,omitempty"` Type string `xml:"type,attr,omitempty"` // XEP-0172 User nicknames Nick string `xml:"http://jabber.org/protocol/nick nick,omitempty"` XMLName string `xml:"presence"` }
Presence represents a message identifying whether an entity is available and the subscription requests/responses for the entity
type PresenceHandler ¶
PresenceHandler handles incoming presence requests
func ToAddressPresenceHandler ¶
func ToAddressPresenceHandler(fn func(subject Address) error) PresenceHandler
ToAddressPresenceHandler calls the function with the To address
type ReceiptAck ¶
type ReceiptAck struct {
ID string `xml:"id,attr"`
}
ReceiptAck represents an acknowledgement that the message with ID has been received.
type Sender ¶
type Sender interface {
Send(i interface{}) error
}
A Sender is an interface which allows sending of arbitrary objects as XML to an XMPP server.
type UnknownElementHandler ¶
type UnknownElementHandler func(*Component, *xml.StartElement) error
UnknownElementHandler handles unknown XML entities sent through XMPP