From ae612c390108097da2a3804c539e07df31eb6a9d Mon Sep 17 00:00:00 2001 From: levi Date: Wed, 12 Jun 2024 13:58:24 +0800 Subject: [PATCH] clear client message queue when closing websocket --- websocket-sharp/WebSocket.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index a9636e6a2..ecb9c9e49 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1569,6 +1569,10 @@ private void init () _messageEventQueue = new Queue (); _forMessageEventQueue = ((ICollection) _messageEventQueue).SyncRoot; _readyState = WebSocketState.New; + OnClose += (o, e) => + { + _messageEventQueue.Clear(); + }; } private void message ()