diff -r d6b7b4cbf50d -r b5de44679389 stream.go --- a/stream.go Wed Dec 28 13:14:46 2011 -0700 +++ b/stream.go Wed Dec 28 13:24:08 2011 -0700 @@ -189,7 +189,7 @@ } } -func (cl *Client) readStream(srvIn <-chan interface{}, cliOut chan<- interface{}) { +func (cl *Client) readStream(srvIn <-chan interface{}, cliOut chan<- Stanza) { defer tryClose(srvIn, cliOut) handlers := make(map[string] func(Stanza) bool) @@ -213,14 +213,19 @@ default: send = true } - if st, ok := x.(Stanza) ; ok && - handlers[st.XId()] != nil { + st, ok := x.(Stanza) + if !ok { + log.Printf("Unhandled non-stanza: %v", + x) + continue + } + if handlers[st.XId()] != nil { f := handlers[st.XId()] handlers[st.XId()] = nil send = f(st) } if send { - cliOut <- x + cliOut <- st } } } @@ -229,7 +234,7 @@ // BUG(cjyar) Disable this loop until resource binding is // complete. Otherwise the app might inject something weird into our // negotiation stream. -func writeStream(srvOut chan<- interface{}, cliIn <-chan interface{}) { +func writeStream(srvOut chan<- interface{}, cliIn <-chan Stanza) { defer tryClose(srvOut, cliIn) for x := range cliIn {