From a8098481d503c757e4c8c039a2b52f958015c598 Mon Sep 17 00:00:00 2001 From: 1 <1@72wo.cn> Date: Sun, 5 Oct 2025 01:47:45 +0000 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9logic=20=E9=95=BF=E6=97=B6?= =?UTF-8?q?=E9=97=B4=E5=90=8E=E6=97=A0=E6=B3=95=E7=99=BB=E5=BD=95=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- common/socket/ServerEvent.go | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/common/socket/ServerEvent.go b/common/socket/ServerEvent.go index d5707bfc..6a1e778d 100644 --- a/common/socket/ServerEvent.go +++ b/common/socket/ServerEvent.go @@ -84,8 +84,8 @@ func (s *Server) OnTraffic(c gnet.Conn) (action gnet.Action) { ws := c.Context().(*player.ClientData).Wsmsg if ws.Tcp { //升级失败时候防止缓冲区溢出 - FF := s.handleTcp(c) - return FF + return s.handleTcp(c) + } tt, len1 := ws.ReadBufferBytes(c) @@ -95,14 +95,16 @@ func (s *Server) OnTraffic(c gnet.Conn) (action gnet.Action) { } ok, action := ws.Upgrade(c) - if !ok { //升级失败,说明是tcp连接 - s.handleTcp(c) + if action != gnet.None { //连接断开 return action - } else { - // fmt.Println(ws.Buf.Bytes()) - c.Read(make([]byte, len1)) } + if !ok { //升级失败,说明是tcp连接 + return s.handleTcp(c) + + } + // fmt.Println(ws.Buf.Bytes()) + c.Read(make([]byte, len1)) if ws.Buf.Len() <= 0 { return gnet.None } @@ -144,7 +146,6 @@ func (s *Server) handleTcp(conn gnet.Conn) (action gnet.Action) { s.parser(conn, data) }) - return } if conn.InboundBuffered() > 0 {