diff options
author | xengineering <me@xengineering.eu> | 2023-07-03 22:17:15 +0200 |
---|---|---|
committer | xengineering <me@xengineering.eu> | 2023-07-03 22:17:15 +0200 |
commit | 2fade1039c1842f08b30da5c95b5542b57e38ec6 (patch) | |
tree | 329ae6641f6b00f1e0cbf65321ac44b90d0c15e4 /xmpp/xml.go | |
parent | cf520b079743ec95d085a439d00b841c253c564a (diff) | |
download | limox-2fade1039c1842f08b30da5c95b5542b57e38ec6.tar limox-2fade1039c1842f08b30da5c95b5542b57e38ec6.tar.zst limox-2fade1039c1842f08b30da5c95b5542b57e38ec6.zip |
Move xml.Encoder to session struct
The encoderDecoder sub-struct of the session struct should be removed in
little steps. This is the first one.
Diffstat (limited to 'xmpp/xml.go')
-rw-r--r-- | xmpp/xml.go | 12 |
1 files changed, 3 insertions, 9 deletions
diff --git a/xmpp/xml.go b/xmpp/xml.go index b0ea77b..f547210 100644 --- a/xmpp/xml.go +++ b/xmpp/xml.go @@ -9,7 +9,6 @@ import ( type encoderDecoder struct { session *session - tx *xml.Encoder rx *xml.Decoder terminator chan bool } @@ -19,11 +18,6 @@ func newEncoderDecoder(s *session) encoderDecoder { ed.session = s - lw := logger{"[TX] "} - w := io.MultiWriter(s.transport, lw) - ed.tx = xml.NewEncoder(w) - ed.tx.Indent("", "") - lr := logger{"[RX] "} r := io.TeeReader(s.transport, lr) ed.rx = xml.NewDecoder(r) @@ -31,7 +25,7 @@ func newEncoderDecoder(s *session) encoderDecoder { return ed } -func (ed *encoderDecoder) encodeToken(t xml.Token) error { +func (s *session) encodeToken(t xml.Token) error { var err error defer func() { if err != nil { @@ -39,11 +33,11 @@ func (ed *encoderDecoder) encodeToken(t xml.Token) error { } }() - err = ed.tx.EncodeToken(t) + err = s.tx.EncodeToken(t) if err != nil { return err } - err = ed.tx.Flush() + err = s.tx.Flush() if err != nil { return err } |