diff --git a/client.go b/client.go index ced1d26..ab1150b 100644 --- a/client.go +++ b/client.go @@ -76,13 +76,15 @@ func (c *Client) readPump() { c.Err = err break } - c.worker.broadcast <- Message{ + msg := Message{ Name: c.Name, Room: c.Room, Code: code, Data: data, conn: c.conn, } + c.worker.server.onMessage(&msg) + c.worker.broadcast <- msg } } diff --git a/worker.go b/worker.go index a87bab9..f6c93d8 100644 --- a/worker.go +++ b/worker.go @@ -70,7 +70,6 @@ func (w *worker) run(ctx context.Context) { return } case message := <-w.broadcast: - w.server.onMessage(&message) for client := range w.clients { if w.server.config.Local || message.conn != client.conn { select {