diff options
Diffstat (limited to 'xmpp/decoder.go')
-rw-r--r-- | xmpp/decoder.go | 57 |
1 files changed, 0 insertions, 57 deletions
diff --git a/xmpp/decoder.go b/xmpp/decoder.go deleted file mode 100644 index 7139b5a..0000000 --- a/xmpp/decoder.go +++ /dev/null @@ -1,57 +0,0 @@ -package xmpp - -import ( - "crypto/tls" - "encoding/xml" - "log" - "os" -) - -type decoder struct { - terminator chan bool - data chan xml.Token - decoder *xml.Decoder - debug *xml.Encoder -} - -func newDecoder(conn *tls.Conn) decoder { - d := decoder{ - make(chan bool), - make(chan xml.Token), - xml.NewDecoder(conn), - xml.NewEncoder(os.Stdout), - } - - d.debug.Indent("S: ", " ") - - return d -} - -func (r *decoder) run() { - for { - select { - case <-r.terminator: - return - default: - t, err := r.decoder.Token() - if t != nil && err == nil { - err := r.debug.EncodeToken(t) - if err != nil { - log.Println("Could not encode received XML token to debug output!") - } - err = r.debug.Flush() - if err != nil { - log.Println("Could not flush debug output after receive!") - } - r.data <- xml.CopyToken(t) - } - if err != nil { - return // FIXME disconnect on parsing error - } - } - } -} - -func (r *decoder) stop() { - r.terminator <- true -} |