diff options
Diffstat (limited to 'xmpp/encoder_decoder.go')
-rw-r--r-- | xmpp/encoder_decoder.go | 24 |
1 files changed, 6 insertions, 18 deletions
diff --git a/xmpp/encoder_decoder.go b/xmpp/encoder_decoder.go index c340b09..6a37c42 100644 --- a/xmpp/encoder_decoder.go +++ b/xmpp/encoder_decoder.go @@ -10,8 +10,7 @@ import ( type encoderDecoder struct { session *session - ct *xml.Encoder // client transport encoder - cl *xml.Encoder // client log encoder + tx *xml.Encoder st *xml.Decoder // server transport decoder sl *xml.Encoder // server log encoder terminator chan bool @@ -22,11 +21,9 @@ func newEncoderDecoder(s *session) encoderDecoder { ed.session = s - ed.ct = xml.NewEncoder(s.transport) - ed.ct.Indent("", " ") - - ed.cl = xml.NewEncoder(os.Stdout) - ed.cl.Indent("C: ", " ") + w := io.MultiWriter(s.transport, os.Stdout) + ed.tx = xml.NewEncoder(w) + ed.tx.Indent("", " ") ed.st = xml.NewDecoder(s.transport) @@ -44,20 +41,11 @@ func (ed *encoderDecoder) encodeToken(t xml.Token) error { } }() - err = ed.ct.EncodeToken(t) - if err != nil { - return err - } - err = ed.ct.Flush() - if err != nil { - return err - } - - err = ed.cl.EncodeToken(t) + err = ed.tx.EncodeToken(t) if err != nil { return err } - err = ed.cl.Flush() + err = ed.tx.Flush() if err != nil { return err } |