diff options
-rw-r--r-- | xmpp.go | 18 |
1 files changed, 13 insertions, 5 deletions
@@ -33,8 +33,8 @@ func xmpp(rxChan chan GuiEvent, txChan chan any, jid string, pwd string) { enc := xml.NewEncoder(conn) dbg := xml.NewEncoder(os.Stdout) - end := sendStreamStart(enc, jid) - defer sendStreamEnd(enc, end) + end := sendStreamStart(enc, dbg, jid) + defer sendStreamEnd(enc, dbg, end) txChan <- XmppConnect @@ -73,7 +73,7 @@ func rxRoutine(conn *tls.Conn, tokens chan xml.Token, terminator chan bool) { case <-terminator: return default: - t, _ := dec.Token() // TODO error handling + t, _ := dec.Token() // TODO error handling if t != nil { tokens <- t } @@ -81,7 +81,7 @@ func rxRoutine(conn *tls.Conn, tokens chan xml.Token, terminator chan bool) { } } -func sendStreamStart(enc *xml.Encoder, jid string) xml.EndElement { +func sendStreamStart(enc *xml.Encoder, dbg *xml.Encoder, jid string) xml.EndElement { start := xml.StartElement{ xml.Name{"jabber:client", "stream:stream"}, []xml.Attr{ @@ -103,10 +103,14 @@ func sendStreamStart(enc *xml.Encoder, jid string) xml.EndElement { log.Fatal("Could not flush XML encoder!") } + dbg.Indent("C: ", " ") + dbg.EncodeToken(start) + dbg.Flush() + return start.End() } -func sendStreamEnd(enc *xml.Encoder, end xml.EndElement) { +func sendStreamEnd(enc *xml.Encoder, dbg *xml.Encoder, end xml.EndElement) { err := enc.EncodeToken(end) if err != nil { log.Fatal("Could not encode stream end!") @@ -116,6 +120,10 @@ func sendStreamEnd(enc *xml.Encoder, end xml.EndElement) { if err != nil { log.Fatal("Could not flush XML encoder!") } + + dbg.Indent("C: ", " ") + dbg.EncodeToken(end) + dbg.Flush() } // domainpart extracts the domain name from a JID / XMPP address. See |