5eae7f4ef7
The URL will be more permanent as this is a place we dedicate as short URL for our go projects.
43 lines
983 B
Go
43 lines
983 B
Go
package xmpp // import "gosrc.io/xmpp"
|
|
|
|
import "encoding/xml"
|
|
|
|
// ============================================================================
|
|
// Presence Packet
|
|
|
|
type Presence struct {
|
|
XMLName xml.Name `xml:"presence"`
|
|
PacketAttrs
|
|
Show string `xml:"show,attr,omitempty"` // away, chat, dnd, xa
|
|
Status string `xml:"status,attr,omitempty"`
|
|
Priority string `xml:"priority,attr,omitempty"`
|
|
Error Err `xml:"error,omitempty"`
|
|
}
|
|
|
|
func (Presence) Name() string {
|
|
return "presence"
|
|
}
|
|
|
|
func NewPresence(from, to, id, lang string) Presence {
|
|
return Presence{
|
|
XMLName: xml.Name{Local: "presence"},
|
|
PacketAttrs: PacketAttrs{
|
|
Id: id,
|
|
From: from,
|
|
To: to,
|
|
Lang: lang,
|
|
},
|
|
}
|
|
}
|
|
|
|
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
|
|
}
|