Documentation
¶
Overview ¶
Package xmpp implements the XMPP IM protocol, as specified in RFC 6120 and 6121.
Index ¶
- Constants
- func RemoveResourceFromJid(jid string) string
- func Resolve(domain string) (host string, port uint16, err error)
- type BooleanFormField
- type ClientCaps
- type ClientError
- type ClientIQ
- type ClientMessage
- type ClientPresence
- type ClientText
- type Config
- type Conn
- func (c *Conn) Cancel(cookie Cookie) bool
- func (c *Conn) Next() (stanza Stanza, err error)
- func (c *Conn) RequestRoster() (<-chan Stanza, Cookie, error)
- func (c *Conn) Send(to, msg string) error
- func (c *Conn) SendIQ(to, typ string, value interface{}) (reply chan Stanza, cookie Cookie, err error)
- func (c *Conn) SendIQReply(to, typ, id string, value interface{}) error
- func (c *Conn) SendPresence(to, typ, id string) error
- func (c *Conn) SendStanza(s interface{}) error
- func (c *Conn) SetCustomStorage(space, local string, s interface{})
- func (c *Conn) SignalPresence(state string) error
- type Cookie
- type Delay
- type DiscoveryFeature
- type DiscoveryIdentity
- type DiscoveryReply
- type EmptyReply
- type ErrorBadRequest
- type ErrorReply
- type FixedFormField
- type Form
- type FormCallback
- type FormField
- type Media
- type MultiSelectionFormField
- type MultiTextFormField
- type RegisterQuery
- type Roster
- type RosterEntry
- type RosterRequest
- type RosterRequestItem
- type SelectionFormField
- type Stanza
- type StreamError
- type TextFormField
- type VersionQuery
- type VersionReply
Constants ¶
const ( NsStream = "http://etherx.jabber.org/streams" NsTLS = "urn:ietf:params:xml:ns:xmpp-tls" NsSASL = "urn:ietf:params:xml:ns:xmpp-sasl" NsBind = "urn:ietf:params:xml:ns:xmpp-bind" NsSession = "urn:ietf:params:xml:ns:xmpp-session" NsClient = "jabber:client" )
Variables ¶
This section is empty.
Functions ¶
func RemoveResourceFromJid ¶
RemoveResourceFromJid returns the user@domain portion of a JID.
Types ¶
type BooleanFormField ¶
BooleanFormField is for a yes/no answer. The Result member should be set to the user's answer.
type ClientCaps ¶
type ClientError ¶
type ClientMessage ¶
type ClientMessage struct { XMLName xml.Name `xml:"jabber:client message"` From string `xml:"from,attr"` Id string `xml:"id,attr"` To string `xml:"to,attr"` Type string `xml:"type,attr"` // chat, error, groupchat, headline, or normal // These should technically be []clientText, // but string is much more convenient. Subject string `xml:"subject"` Body string `xml:"body"` Thread string `xml:"thread"` Delay *Delay `xml:"delay,omitempty"` }
RFC 3921 B.1 jabber:client
type ClientPresence ¶
type ClientPresence struct { XMLName xml.Name `xml:"jabber:client presence"` From string `xml:"from,attr,omitempty"` Id string `xml:"id,attr,omitempty"` To string `xml:"to,attr,omitempty"` Type string `xml:"type,attr,omitempty"` // error, probe, subscribe, subscribed, unavailable, unsubscribe, unsubscribed Lang string `xml:"lang,attr,omitempty"` Show string `xml:"show,omitempty"` // away, chat, dnd, xa Status string `xml:"status,omitempty"` // sb []clientText Priority string `xml:"priority,omitempty"` Caps *ClientCaps `xml:"c"` Error *ClientError `xml:"error"` Delay Delay `xml:"delay"` }
type ClientText ¶
type Config ¶
type Config struct { // Conn is the connection to the server, if non-nill. Conn net.Conn // InLog is an optional Writer which receives the raw contents of the // XML from the server. InLog io.Writer // OutLog is an optional Writer which receives the raw XML sent to the // server. OutLog io.Writer // Log is an optional Writer which receives human readable log messages // during the connection. Log io.Writer // CreateCallback, if not nil, causes a new account to be created on // the server. The callback is needed in order to be able to handle // XMPP forms. CreateCallback FormCallback // TrustedAddress, if true, means that the address passed to Dial is // trusted and that certificates for that name should be accepted. TrustedAddress bool // Archive determines whether we disable archiving for messages. If // false, XML is sent with each message to disable recording on the // server. Archive bool // ServerCertificateSHA256 contains the SHA-256 hash of the server's // leaf certificate, or may be empty to use normal X.509 verification. // If this is specified then normal X.509 verification is disabled. ServerCertificateSHA256 []byte // SkipTLS, if true, causes the TLS handshake to be skipped. // WARNING: this should only be used if Conn is already secure. SkipTLS bool // TLSConfig contains the configuration to be used by the TLS // handshake. If nil, sensible defaults will be used. TLSConfig *tls.Config }
Config contains options for an XMPP connection.
type Conn ¶
type Conn struct {
// contains filtered or unexported fields
}
Conn represents a connection to an XMPP server.
func (*Conn) Next ¶
Next reads stanzas from the server. If the stanza is a reply, it dispatches it to the correct channel and reads the next message. Otherwise it returns the stanza for processing.
func (*Conn) RequestRoster ¶
RequestRoster requests the user's roster from the server. It returns a channel on which the reply can be read when received and a Cookie that can be used to cancel the request.
func (*Conn) SendIQ ¶
func (c *Conn) SendIQ(to, typ string, value interface{}) (reply chan Stanza, cookie Cookie, err error)
SendIQ sends an info/query message to the given user. It returns a channel on which the reply can be read when received and a Cookie that can be used to cancel the request.
func (*Conn) SendIQReply ¶
SendIQReply sends a reply to an IQ query.
func (*Conn) SendPresence ¶
SendPresence sends a presence stanza. If id is empty, a unique id is generated.
func (*Conn) SendStanza ¶
func (*Conn) SetCustomStorage ¶
func (*Conn) SignalPresence ¶
type Delay ¶
type Delay struct { XMLName xml.Name `xml:"urn:xmpp:delay delay"` From string `xml:"from,attr,omitempty"` Stamp string `xml:"stamp,attr"` Body string `xml:",chardata"` }
XEP-0203: Delayed Delivery of <message/> and <presence/> stanzas.
type DiscoveryFeature ¶
type DiscoveryIdentity ¶
type DiscoveryReply ¶
type DiscoveryReply struct { XMLName xml.Name `xml:"http://jabber.org/protocol/disco#info query"` Node string `xml:"node"` Identities []DiscoveryIdentity `xml:"identity"` Features []DiscoveryFeature `xml:"feature"` Forms []Form `xml:"jabber:x:data x"` }
func (*DiscoveryReply) VerificationString ¶
func (r *DiscoveryReply) VerificationString() (string, error)
VerificationString returns a SHA-1 verification string as defined in XEP-0115. See http://xmpp.org/extensions/xep-0115.html#ver
type ErrorBadRequest ¶
type ErrorBadRequest struct {
XMLName xml.Name `xml:"urn:ietf:params:xml:ns:xmpp-stanzas bad-request"`
}
ErrorBadRequest reflects a bad-request stanza. See http://xmpp.org/rfcs/rfc6120.html#stanzas-error-conditions-bad-request
type ErrorReply ¶
type ErrorReply struct { XMLName xml.Name `xml:"error"` Type string `xml:"type,attr"` Error interface{} `xml:"error"` }
ErrorReply reflects an XMPP error stanza. See http://xmpp.org/rfcs/rfc6120.html#stanzas-error-syntax
type FixedFormField ¶
FixedFormField is used to indicate a section heading. It's for the form to send data to the user rather than the other way around.
type FormCallback ¶
FormCallback is the type of a function called to process a form. The argument is a list of pointers to FormField types. The function should type cast the elements, prompt the user and fill in the result field in each struct.
type FormField ¶
type FormField struct { // Label is a human readable label for this field. Label string // Type is the XMPP-internal type of this field. One should type cast // rather than inspect this. Type string // Name gives the internal name of the field. Name string Required bool // Media contains one of more items of media associated with this // field and, for each item, one or more representations of it. Media [][]Media }
FormField is the type of a generic form field. One should type cast to a specific type of field before processing.
type MultiSelectionFormField ¶
MultiSelectionFormField asks the user to pick a subset of possible choices. The Result member should be set to a series of indexes of the Results array.
type MultiTextFormField ¶
MultiTextFormField is for the entry of a several textual items. The Results member should be set to the data entered.
type RegisterQuery ¶
type Roster ¶
type Roster struct { XMLName xml.Name `xml:"jabber:iq:roster query"` Item []RosterEntry `xml:"item"` }
type RosterEntry ¶
type RosterEntry struct { Jid string `xml:"jid,attr"` Subscription string `xml:"subscription,attr"` Name string `xml:"name,attr"` Group []string `xml:"group"` }
func ParseRoster ¶
func ParseRoster(reply Stanza) ([]RosterEntry, error)
ParseRoster extracts roster information from the given Stanza.
type RosterRequest ¶
type RosterRequest struct { XMLName xml.Name `xml:"jabber:iq:roster query"` Item RosterRequestItem `xml:"item"` }
RosterRequest is used to request that the server update the user's roster. See RFC 6121, section 2.3.
type RosterRequestItem ¶
type SelectionFormField ¶
SelectionFormField asks the user to pick a single element from a set of choices. The Result member should be set to an index of the Values array.
type StreamError ¶
type TextFormField ¶
type TextFormField struct { FormField Default string Result string // Private is true if this is a password or other sensitive entry. Private bool }
TextFormField is for the entry of a single textual item. The Result member should be set to the data entered.