Skip to content

Commit

Permalink
Xmpp ping fixed to use the obtained jid.
Browse files Browse the repository at this point in the history
Though a client function, ping does not use the client jid.
Fixed ping to use the obtained jid and configured server domain by default.
Client now exposes jid.
  • Loading branch information
bolshoy committed Apr 10, 2016
1 parent 0e63271 commit e3871c2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
4 changes: 4 additions & 0 deletions xmpp.go
Expand Up @@ -64,6 +64,10 @@ type Client struct {
p *xml.Decoder
}

func (c *Client) JID() string {
return c.jid
}

func connect(host, user, passwd string) (net.Conn, error) {
addr := host

Expand Down
6 changes: 6 additions & 0 deletions xmpp_ping.go
Expand Up @@ -5,6 +5,12 @@ import (
)

func (c *Client) PingC2S(jid, server string) error {
if jid == "" {
jid = c.jid
}
if server == "" {
server = c.domain
}
_, err := fmt.Fprintf(c.conn, "<iq from='%s' to='%s' id='c2s1' type='get'>\n"+
"<ping xmlns='urn:xmpp:ping'/>\n"+
"</iq>",
Expand Down

0 comments on commit e3871c2

Please sign in to comment.