diff options
Diffstat (limited to 'xmpp/encoder_decoder.go')
-rw-r--r-- | xmpp/encoder_decoder.go | 19 |
1 files changed, 4 insertions, 15 deletions
diff --git a/xmpp/encoder_decoder.go b/xmpp/encoder_decoder.go index 6a37c42..e7eeaf8 100644 --- a/xmpp/encoder_decoder.go +++ b/xmpp/encoder_decoder.go @@ -11,8 +11,7 @@ import ( type encoderDecoder struct { session *session tx *xml.Encoder - st *xml.Decoder // server transport decoder - sl *xml.Encoder // server log encoder + rx *xml.Decoder terminator chan bool } @@ -25,10 +24,8 @@ func newEncoderDecoder(s *session) encoderDecoder { ed.tx = xml.NewEncoder(w) ed.tx.Indent("", " ") - ed.st = xml.NewDecoder(s.transport) - - ed.sl = xml.NewEncoder(os.Stdout) - ed.sl.Indent("S: ", " ") + r := io.TeeReader(s.transport, os.Stdout) + ed.rx = xml.NewDecoder(r) return ed } @@ -59,16 +56,8 @@ func (ed *encoderDecoder) run() { case <-ed.terminator: return default: - t, err := ed.st.Token() + t, err := ed.rx.Token() if t != nil && err == nil { - err = ed.sl.EncodeToken(t) - if err != nil { - log.Println("Could not encode to server stream log") - } - err = ed.sl.Flush() - if err != nil { - log.Println("Could not flush server stream log") - } c := xml.CopyToken(t) ed.session.rx <- c } |