forked from jshiffer/go-xmpp
return Presence messages in Recv
This commit is contained in:
parent
99516ec31f
commit
1e9dc674d1
20
xmpp.go
20
xmpp.go
@ -222,15 +222,25 @@ type Chat struct {
|
||||
Text string
|
||||
}
|
||||
|
||||
type Presence struct {
|
||||
From string
|
||||
To string
|
||||
Type string
|
||||
Show string
|
||||
}
|
||||
|
||||
// Recv wait next token of chat.
|
||||
func (c *Client) Recv() (chat Chat, err error) {
|
||||
func (c *Client) Recv() (event interface{}, err error) {
|
||||
for {
|
||||
_, val, err := next(c.p)
|
||||
if err != nil {
|
||||
return Chat{}, err
|
||||
}
|
||||
if v, ok := val.(*clientMessage); ok {
|
||||
switch v := val.(type) {
|
||||
case *clientMessage:
|
||||
return Chat{v.From, v.Type, v.Body}, nil
|
||||
case *clientPresence:
|
||||
return Presence{v.From, v.To, v.Type, v.Show}, nil
|
||||
}
|
||||
}
|
||||
panic("unreachable")
|
||||
@ -340,9 +350,9 @@ type clientPresence struct {
|
||||
Type string `xml:"type,attr"` // error, probe, subscribe, subscribed, unavailable, unsubscribe, unsubscribed
|
||||
Lang string `xml:"lang,attr"`
|
||||
|
||||
Show string `xml:"show,attr"`// away, chat, dnd, xa
|
||||
Status string `xml:"status,attr"`// sb []clientText
|
||||
Priority string `xml:"priority,attr"`
|
||||
Show string `xml:"show"` // away, chat, dnd, xa
|
||||
Status string `xml:"status,attr"` // sb []clientText
|
||||
Priority string `xml:"priority,attr"`
|
||||
Error *clientError
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user