forked from jshiffer/go-xmpp
Recv: handle clientIQ
When sending a successful Client-To-Server Ping, one gets a Pong that looks like this: <iq from='capulet.lit' to='juliet@capulet.lit/balcony' id='c2s1' type='result'/> (http://xmpp.org/extensions/xep-0199.html#c2s)
This commit is contained in:
parent
7d83a73298
commit
c84fc9afab
24
xmpp.go
24
xmpp.go
@ -173,6 +173,7 @@ func (o Options) NewClient() (*Client, error) {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if strings.LastIndex(o.Host, ":") > 0 {
|
||||
host = host[:strings.LastIndex(o.Host, ":")]
|
||||
}
|
||||
@ -555,6 +556,13 @@ type Presence struct {
|
||||
Status string
|
||||
}
|
||||
|
||||
type IQ struct {
|
||||
ID string
|
||||
From string
|
||||
To string
|
||||
Type string
|
||||
}
|
||||
|
||||
// Recv waits to receive the next XMPP stanza.
|
||||
// Return type is either a presence notification or a chat message.
|
||||
func (c *Client) Recv() (stanza interface{}, err error) {
|
||||
@ -585,6 +593,14 @@ func (c *Client) Recv() (stanza interface{}, err error) {
|
||||
return Chat{Type: "roster", Roster: r}, nil
|
||||
case *clientPresence:
|
||||
return Presence{v.From, v.To, v.Type, v.Show, v.Status}, nil
|
||||
case *clientIQ:
|
||||
result := IQ{
|
||||
ID: v.ID,
|
||||
From: v.From,
|
||||
To: v.To,
|
||||
Type: v.Type,
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -724,10 +740,10 @@ type clientPresence struct {
|
||||
|
||||
type clientIQ struct { // info/query
|
||||
XMLName xml.Name `xml:"jabber:client iq"`
|
||||
From string `xml:",attr"`
|
||||
ID string `xml:",attr"`
|
||||
To string `xml:",attr"`
|
||||
Type string `xml:",attr"` // error, get, result, set
|
||||
From string `xml:"from,attr"`
|
||||
ID string `xml:"id,attr"`
|
||||
To string `xml:"to,attr"`
|
||||
Type string `xml:"type,attr"` // error, get, result, set
|
||||
Error clientError
|
||||
Bind bindBind
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user