mirror of
https://github.com/FluuxIO/go-xmpp.git
synced 2024-11-21 10:02:00 -08:00
d9fdff0839
* Add constants (enumlike) for stanza types * NewIQ, NewMessage and NewPresence are now initialized with the Attrs struct * Update examples * Do not export backoff code. For now, we do not need to expose backoff in the documentation * Make presence priority an int8
39 lines
922 B
Go
39 lines
922 B
Go
package xmpp
|
|
|
|
import "encoding/xml"
|
|
|
|
// ============================================================================
|
|
// Presence Packet
|
|
|
|
// Presence implements RFC 6120 - A.5 Client Namespace (a part)
|
|
type Presence struct {
|
|
XMLName xml.Name `xml:"presence"`
|
|
Attrs
|
|
Show PresenceShow `xml:"show,omitempty"`
|
|
Status string `xml:"status,omitempty"`
|
|
Priority int8 `xml:"priority,omitempty"` // default: 0
|
|
Error Err `xml:"error,omitempty"`
|
|
}
|
|
|
|
func (Presence) Name() string {
|
|
return "presence"
|
|
}
|
|
|
|
func NewPresence(a Attrs) Presence {
|
|
return Presence{
|
|
XMLName: xml.Name{Local: "presence"},
|
|
Attrs: a,
|
|
}
|
|
}
|
|
|
|
type presenceDecoder struct{}
|
|
|
|
var presence presenceDecoder
|
|
|
|
func (presenceDecoder) decode(p *xml.Decoder, se xml.StartElement) (Presence, error) {
|
|
var packet Presence
|
|
err := p.DecodeElement(&packet, &se)
|
|
// TODO Add default presence type (when omitted)
|
|
return packet, err
|
|
}
|