forked from jshiffer/go-xmpp
implement discovery extension
This commit is contained in:
parent
12d5633a9d
commit
bacbdeb205
3
xmpp.go
3
xmpp.go
@ -417,7 +417,7 @@ func (c *Client) init(o *Options) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Generate a uniqe cookie
|
// Generate a unique cookie
|
||||||
cookie := getCookie()
|
cookie := getCookie()
|
||||||
|
|
||||||
// Send IQ message asking to bind to the local user name.
|
// Send IQ message asking to bind to the local user name.
|
||||||
@ -434,6 +434,7 @@ func (c *Client) init(o *Options) error {
|
|||||||
return errors.New("<iq> result missing <bind>")
|
return errors.New("<iq> result missing <bind>")
|
||||||
}
|
}
|
||||||
c.jid = iq.Bind.Jid // our local id
|
c.jid = iq.Bind.Jid // our local id
|
||||||
|
c.domain = domain
|
||||||
|
|
||||||
if o.Session {
|
if o.Session {
|
||||||
//if server support session, open it
|
//if server support session, open it
|
||||||
|
12
xmpp_discovery.go
Normal file
12
xmpp_discovery.go
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
package xmpp
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
)
|
||||||
|
|
||||||
|
const xmlIqGet = "<iq from='%s' to='%s' id='%d' type='get'><query xmlns='http://jabber.org/protocol/disco#items'/></iq>"
|
||||||
|
|
||||||
|
func (c *Client) Discovery() {
|
||||||
|
cookie := getCookie()
|
||||||
|
fmt.Fprintf(c.conn, xmlIqGet, xmlEscape(c.jid), xmlEscape(c.domain), cookie)
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user