Documentation ¶
Index ¶
- Constants
- Variables
- func AddElement(e interface{})
- func GetElement(name xml.Name) interface{}
- func HandleStanza(handler StanzaHandler, stanza Stanza) bool
- func Identify(s interface{}) (id xml.Name)
- func Open(handler Handler, cfg *Config) error
- type Abort
- type Auth
- type Authenticator
- type Bind
- type Broadcast
- type Callbacks
- type Challenge
- type Closer
- type Compression
- type Config
- type Conn
- func (c *Conn) Authenticate(username, password string) error
- func (c *Conn) Bind(resourceName string) (JID, error)
- func (c *Conn) Close() error
- func (c *Conn) Features() *Features
- func (c *Conn) Read() (interface{}, error)
- func (c *Conn) RestartStream(transport io.ReadWriteCloser) (err error)
- func (c *Conn) StartTLS(serverName string) error
- func (c *Conn) Transport() io.ReadWriteCloser
- func (c *Conn) Write(msg interface{}) error
- type Container
- type Credentials
- type Error
- type Features
- type Filter
- type Generic
- type Handler
- type IQ
- func (iq *IQ) GetFrom() JID
- func (iq *IQ) GetID() string
- func (iq *IQ) GetLang() string
- func (iq *IQ) GetTo() JID
- func (iq *IQ) GetType() string
- func (iq *IQ) MarshalXML(enc *xml.Encoder, start xml.StartElement) error
- func (iq *IQ) Response(items ...interface{}) *IQ
- func (iq *IQ) Result() bool
- func (iq *IQ) SetFrom(s JID)
- func (iq *IQ) SetID(s string)
- func (iq *IQ) SetLang(s string)
- func (iq *IQ) SetTo(s JID)
- func (iq *IQ) SetType(s string)
- func (iq *IQ) UnmarshalXML(dec *xml.Decoder, start xml.StartElement) error
- type IQCallback
- type JID
- type Logger
- type Mechanisms
- type Message
- func (m *Message) Chat() bool
- func (m *Message) Error() bool
- func (m *Message) GetFrom() JID
- func (m *Message) GetID() string
- func (m *Message) GetLang() string
- func (m *Message) GetTo() JID
- func (m *Message) GetType() string
- func (m *Message) Headline() bool
- func (m *Message) MarshalXML(enc *xml.Encoder, start xml.StartElement) error
- func (m *Message) Normal() bool
- func (m *Message) Reply(format string, a ...interface{}) *Message
- func (m *Message) SetFrom(s JID)
- func (m *Message) SetID(s string)
- func (m *Message) SetLang(s string)
- func (m *Message) SetTo(s JID)
- func (m *Message) SetType(s string)
- func (m *Message) UnmarshalXML(dec *xml.Decoder, start xml.StartElement) error
- type MessageCallback
- type PlainAuth
- type Presence
- func (m *Presence) GetFrom() JID
- func (m *Presence) GetID() string
- func (m *Presence) GetLang() string
- func (m *Presence) GetTo() JID
- func (m *Presence) GetType() string
- func (p *Presence) MarshalXML(enc *xml.Encoder, start xml.StartElement) error
- func (m *Presence) SetFrom(s JID)
- func (m *Presence) SetID(s string)
- func (m *Presence) SetLang(s string)
- func (m *Presence) SetTo(s JID)
- func (m *Presence) SetType(s string)
- func (p *Presence) UnmarshalXML(dec *xml.Decoder, start xml.StartElement) error
- type PresenceCallback
- type Proceed
- type ReadWriteCloser
- type ReadWriter
- type Reader
- type Register
- type Response
- type RosterItem
- type RosterQuery
- type SASLFailure
- type ScramAuth
- type Session
- type Stanza
- type StanzaHandler
- type StartTLS
- type Stream
- type StreamHeader
- type Success
- type TLSFailure
- type UniqueID
- type Writer
Constants ¶
const ( TLSRequired = iota TLSPreferred TLSDisabled )
const ( Away = "away" Chat = "chat" DND = "dnd" XA = "xa" )
const ( NamespaceClient = "jabber:client" NamespaceServer = "jabber:server" DefaultVersion = "1.0" )
Stream namespaces
Variables ¶
var DefinedConditions = []string{
"bad-format",
"bad-namespace-prefix",
"conflict",
"connection-timeout",
"host-gone",
"host-unknown",
"improper-addressing",
"internal-server-error",
"invalid-from",
"invalid-namespace",
"invalid-xml",
"not-authorized",
"not-well-formed",
"policy-violation",
"remote-connection-failed",
"reset",
"resource-constraint",
"restricted-xml",
"see-other-host",
"system-shutdown",
"undefined-condition",
"unsupported-encoding",
"unsupported-feature",
"unsupported-stanza-type",
"unsupported-version",
}
DefinedConditions is a list of conditions defined by RFC6120
var ErrEndOfElement = errors.New("end of element")
var ErrEndOfStream = errors.New("end of stream")
ErrEndOfStream indicates the XMPP stream has ended
var ErrNoPrototype = errors.New("prototype not found")
var ErrStreamError = errors.New("stream error")
ErrStreamError indicates invalid stream data
Functions ¶
func AddElement ¶
func AddElement(e interface{})
func GetElement ¶
func HandleStanza ¶
func HandleStanza(handler StanzaHandler, stanza Stanza) bool
HandleStanza routes a stanza to a typed stanza handler
Types ¶
type Authenticator ¶
Authenticator defines an interface for SASL authentication
func NewPlainAuthenticator ¶
func NewPlainAuthenticator(creds Credentials) Authenticator
NewPlainAuthenticator instantiates a PLAIN authenticator using provided credentials
func NewScramSHA1Authenticator ¶
func NewScramSHA1Authenticator(creds Credentials) Authenticator
type Broadcast ¶
type Broadcast struct {
// contains filtered or unexported fields
}
Broadcast routes XMPP events to mutiple handlers
func (*Broadcast) HandleStanza ¶
HandleStanza routes a stanza
type Callbacks ¶
type Callbacks struct { Session // contains filtered or unexported fields }
func (*Callbacks) WriteMessage ¶
func (c *Callbacks) WriteMessage(msg *Message, callback MessageCallback) error
func (*Callbacks) WritePresence ¶
func (c *Callbacks) WritePresence(p *Presence, callback PresenceCallback) error
type Compression ¶
type Conn ¶
type Conn struct {
// contains filtered or unexported fields
}
Conn represents an XMPP connection
func (*Conn) Authenticate ¶
Authenticate authenticates to the server and restarts the stream
func (*Conn) RestartStream ¶
func (c *Conn) RestartStream(transport io.ReadWriteCloser) (err error)
RestartStream restarts the current stream. If transport is provided, it replaces the currently used transport.
func (*Conn) Transport ¶
func (c *Conn) Transport() io.ReadWriteCloser
Transport returns the transport used for the stream
type Container ¶
type Container struct {
Children []interface{} `xml:"-"`
}
func (*Container) Child ¶
func (c *Container) Child(t interface{}) interface{}
Child returns the first child with a given name
func (*Container) ChildCount ¶
ChildCount returns the number of children with a given name
type Credentials ¶
Credentials holds authentication information
type Features ¶
type Features struct { XMLName xml.Name `xml:"http://etherx.jabber.org/streams features"` Container }
func (*Features) MarshalXML ¶
func (*Features) UnmarshalXML ¶
type Generic ¶
type Generic struct { XMLName xml.Name Attrs map[string]string `xml:"-"` Text string `xml:",chardata"` Container }
A Generic represents an unknown XML element
func (*Generic) MarshalXML ¶
MarshalXML implements XML encoding
func (*Generic) UnmarshalXML ¶
UnmarshalXML implements XML decoding
type IQ ¶
type IQ struct { XMLName xml.Name `xml:"iq"` ID string `xml:"id,attr,omitempty"` To JID `xml:"to,attr,omitempty"` From JID `xml:"from,attr,omitempty"` Type string `xml:"type,attr,omitempty"` Lang string `xml:"lang,attr,omitempty"` Container }
IQ represents an IQ stanza
func (*IQ) MarshalXML ¶
MarshalXML marshals IQ to XML
func (*IQ) UnmarshalXML ¶
UnmarshalXML unmarshals an IQ from XML
type IQCallback ¶
type IQCallback func(*IQ)
type JID ¶
type JID string
JID is the type used to store JIDs
type Mechanisms ¶
type Mechanisms struct { XMLName xml.Name `xml:"urn:ietf:params:xml:ns:xmpp-sasl mechanisms"` Mechanisms []string `xml:"mechanism"` }
func (*Mechanisms) Include ¶
func (m *Mechanisms) Include(name string) bool
type Message ¶
type Message struct { XMLName xml.Name `xml:"message"` ID string `xml:"id,attr,omitempty"` To JID `xml:"to,attr,omitempty"` From JID `xml:"from,attr,omitempty"` Type string `xml:"type,attr,omitempty"` Lang string `xml:"lang,attr,omitempty"` Subject string `xml:"subject,omitempty"` Body string `xml:"body,omitempty"` Thread string `xml:"thread,omitempty"` Container }
A Message represents a message stanza
func (*Message) MarshalXML ¶
func (*Message) UnmarshalXML ¶
type MessageCallback ¶
type MessageCallback func(*Message)
type PlainAuth ¶
PlainAuth implements a plain SASL authentication
func (*PlainAuth) Challenge ¶
Challenge satisfies Authenticator interface. It returns an empty string since PLAIN mechanism doesn't support challenges.
type Presence ¶
type Presence struct { XMLName xml.Name `xml:"presence"` ID string `xml:"id,attr,omitempty"` To JID `xml:"to,attr,omitempty"` From JID `xml:"from,attr,omitempty"` Type string `xml:"type,attr,omitempty"` Lang string `xml:"lang,attr,omitempty"` Show string `xml:"show,omitempty"` Status string `xml:"status,omitempty"` Priority int `xml:"priority,omitempty"` Container }
func (*Presence) MarshalXML ¶
func (*Presence) UnmarshalXML ¶
type PresenceCallback ¶
type PresenceCallback func(*Presence)
type ReadWriteCloser ¶
type ReadWriter ¶
type RosterItem ¶
type RosterItem struct { XMLName xml.Name `xml:"item"` JID JID `xml:"jid,attr"` Name string `xml:"name,attr,omitempty"` Subscription string `xml:"subscription,attr,omitempty"` Group []string `xml:"group,omitempty"` }
RosterItem represents a roster item
type RosterQuery ¶
type RosterQuery struct { XMLName xml.Name `xml:"jabber:iq:roster query"` Items []RosterItem `xml:"item"` }
RosterQuery represents a roster query element
type SASLFailure ¶
type StanzaHandler ¶
type StanzaHandler interface{}
StanzaHandler defines an interface for specific stanza handler
type Stream ¶
type Stream struct {
// contains filtered or unexported fields
}
Stream manages a bidirectional XMPP stream using an underlying transport
func NewStream ¶
func NewStream(transport io.ReadWriter) *Stream
NewStream instantiates a new stream using the provided transport
func (*Stream) ReadHeader ¶
func (s *Stream) ReadHeader() (*StreamHeader, error)
ReadHeader reads and returns a stream header. It ignores the first ProcInst read from the stream.
func (*Stream) Transport ¶
func (s *Stream) Transport() io.ReadWriter
Transport returns the underlying transport object
func (*Stream) WriteHeader ¶
func (s *Stream) WriteHeader(stream *StreamHeader) error
WriteHeader writes a stream header to the stream.
type StreamHeader ¶
StreamHeader represents stream info exchanged in the initial <stream/> element
func NewHeader ¶
func NewHeader(namesapce string, from JID, to JID) *StreamHeader
NewHeader returns a stream header in client protocol namespace
func ParseStreamHeader ¶
func ParseStreamHeader(start *xml.StartElement) *StreamHeader
ParseStreamHeader decodes the opening of the XML stream without touching the content of the stream
func (*StreamHeader) Reply ¶
func (header *StreamHeader) Reply(id string) *StreamHeader
Reply returns a server stream header
func (*StreamHeader) XMLStartElement ¶
func (header *StreamHeader) XMLStartElement() (start xml.StartElement)
XMLStartElement returns an XML start element containing all stream info
type TLSFailure ¶
Source Files ¶
- auth.go
- auth_plain.go
- auth_scram.go
- broadcast.go
- callbacks.go
- config.go
- conn.go
- consts.go
- container.go
- core_elements.go
- elements.go
- error.go
- errors.go
- features.go
- filter.go
- generic.go
- handlers.go
- identify.go
- init.go
- iq.go
- jid.go
- message.go
- presence.go
- proxy.go
- resolver.go
- sasl.go
- session.go
- stanza.go
- stream.go
- stream_header.go
- tee.go
- tls.go
- unqiue_id.go