From eb3926e575c3720331dac47dde4810499d61accf Mon Sep 17 00:00:00 2001 From: mountain Date: Wed, 14 Feb 2024 11:08:22 +0900 Subject: [PATCH] =?UTF-8?q?conn=20=EC=A0=95=EB=A6=AC=EC=8B=9C=20=EB=84=90?= =?UTF-8?q?=20=EC=B2=B4=ED=81=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- wshandler/wshandler.go | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/wshandler/wshandler.go b/wshandler/wshandler.go index 35ce28f..17c6756 100644 --- a/wshandler/wshandler.go +++ b/wshandler/wshandler.go @@ -295,10 +295,20 @@ func (ws *WebsocketHandler) mainLoop(ctx context.Context) { return room } + shutdownConn := func(c *wsconn) { + defer func() { + r := recover() + if r != nil { + logger.Println(r) + } + }() + ws.ClientDisconnected(c) + c.Close() + } + defer func() { for _, conn := range entireConns { - ws.ClientDisconnected(conn) - conn.Close() + shutdownConn(conn) } }()