forked from xmppo/go-xmpp
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
expose information queries for custom extensions
- Loading branch information
james lawrence
committed
Jun 22, 2016
1 parent
aeb80dd
commit c7af92b
Showing
3 changed files
with
32 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package xmpp | ||
|
||
import ( | ||
"fmt" | ||
"strconv" | ||
) | ||
|
||
const IQTypeGet = "get" | ||
const IQTypeSet = "set" | ||
const IQTypeResult = "result" | ||
|
||
func (c *Client) Discovery() (string, error) { | ||
const namespace = "http://jabber.org/protocol/disco#items" | ||
// use getCookie for a pseudo random id. | ||
reqID := strconv.FormatUint(uint64(getCookie()), 10) | ||
return c.RawInformationQuery(c.jid, c.domain, reqID, IQTypeGet, namespace, "") | ||
} | ||
|
||
// RawInformationQuery sends an information query request to the server. | ||
func (c *Client) RawInformationQuery(from, to, id, iqType, requestNamespace, body string) (string, error) { | ||
const xmlIQ = "<iq from='%s' to='%s' id='%s' type='%s'><query xmlns='%s'>%s</query></iq>" | ||
_, err := fmt.Fprintf(c.conn, xmlIQ, xmlEscape(from), xmlEscape(to), id, iqType, requestNamespace, body) | ||
return id, err | ||
} |