Rework printing of sent stanzas when debug is enabled (#148)

* Rework printing of sent stanzas when debug is enabled

This got reworked to also work with multiple connections
as pointed out by @vcabbage in
https://github.com/mattn/go-xmpp/pull/141#issuecomment-1557334066

* Remove StanzaWriter.
This commit is contained in:
Martin
2023-07-28 16:42:12 +02:00
committed by GitHub
parent bef3e549f7
commit 98ff0d4df7
5 changed files with 47 additions and 47 deletions
+3 -3
View File
@@ -11,7 +11,7 @@ func (c *Client) PingC2S(jid, server string) error {
if server == "" {
server = c.domain
}
_, err := fmt.Fprintf(StanzaWriter, "<iq from='%s' to='%s' id='c2s1' type='get'>\n"+
_, err := fmt.Fprintf(c.stanzaWriter, "<iq from='%s' to='%s' id='c2s1' type='get'>\n"+
"<ping xmlns='urn:xmpp:ping'/>\n"+
"</iq>",
xmlEscape(jid), xmlEscape(server))
@@ -19,7 +19,7 @@ func (c *Client) PingC2S(jid, server string) error {
}
func (c *Client) PingS2S(fromServer, toServer string) error {
_, err := fmt.Fprintf(StanzaWriter, "<iq from='%s' to='%s' id='s2s1' type='get'>\n"+
_, err := fmt.Fprintf(c.stanzaWriter, "<iq from='%s' to='%s' id='s2s1' type='get'>\n"+
"<ping xmlns='urn:xmpp:ping'/>\n"+
"</iq>",
xmlEscape(fromServer), xmlEscape(toServer))
@@ -27,7 +27,7 @@ func (c *Client) PingS2S(fromServer, toServer string) error {
}
func (c *Client) SendResultPing(id, toServer string) error {
_, err := fmt.Fprintf(StanzaWriter, "<iq type='result' to='%s' id='%s'/>",
_, err := fmt.Fprintf(c.stanzaWriter, "<iq type='result' to='%s' id='%s'/>",
xmlEscape(toServer), xmlEscape(id))
return err
}