From 5537b5016b9296cf122565d0fa93175f9ed64073 Mon Sep 17 00:00:00 2001 From: hongcha Date: Sun, 6 Aug 2023 12:52:25 +0800 Subject: [PATCH] fix(onmessage): trigger --- client.go | 4 +++- worker.go | 1 - 2 files changed, 3 insertions(+), 2 deletions(-) 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 {