Skip to content

Commit

Permalink
implement discovery extension
Browse files Browse the repository at this point in the history
  • Loading branch information
James Lawrence authored and James Lawrence committed May 6, 2016
1 parent 12d5633 commit bacbdeb
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
3 changes: 2 additions & 1 deletion xmpp.go
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ func (c *Client) init(o *Options) error {
return err
}

// Generate a uniqe cookie
// Generate a unique cookie
cookie := getCookie()

// Send IQ message asking to bind to the local user name.
Expand All @@ -434,6 +434,7 @@ func (c *Client) init(o *Options) error {
return errors.New("<iq> result missing <bind>")
}
c.jid = iq.Bind.Jid // our local id
c.domain = domain

if o.Session {
//if server support session, open it
Expand Down
12 changes: 12 additions & 0 deletions xmpp_discovery.go
Original file line number Diff line number Diff line change
@@ -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)
}

0 comments on commit bacbdeb

Please sign in to comment.