diff --git a/examples/chat/client.go b/examples/chat/client.go index 2646847..ecfd9a7 100644 --- a/examples/chat/client.go +++ b/examples/chat/client.go @@ -129,6 +129,9 @@ func serveWs(hub *Hub, w http.ResponseWriter, r *http.Request) { } client := &Client{hub: hub, conn: conn, send: make(chan []byte, 256)} client.hub.register <- client + + // Allow collection of memory referenced by the caller by doing all work in + // new goroutines. go client.writePump() - client.readPump() + go client.readPump() }