fix(socket): 优化 TCP 连接处理和玩家昵称处理
- 在 ServerEvent.go 中增加 TCP 连接的特殊处理逻辑,防止缓冲区溢出 - 修改 CreatePlayer.go 中的昵称处理,去除多余的空格 - 优化 mapout.go 中的玩家离开地图通知逻辑 - 在 wscodec.go 中增加对 TCP 连接的识别和处理
This commit is contained in:
@@ -92,6 +92,11 @@ func (s *Server) OnTraffic(c gnet.Conn) (action gnet.Action) {
|
||||
}
|
||||
|
||||
ws := c.Context().(*service.ClientData).Wsmsg
|
||||
if ws.Tcp { //升级失败时候防止缓冲区溢出
|
||||
s.handleTcp(c)
|
||||
return gnet.None
|
||||
}
|
||||
|
||||
tt, len1 := ws.ReadBufferBytes(c)
|
||||
if tt == gnet.Close {
|
||||
|
||||
@@ -99,7 +104,7 @@ func (s *Server) OnTraffic(c gnet.Conn) (action gnet.Action) {
|
||||
}
|
||||
|
||||
ok, action := ws.Upgrade(c)
|
||||
if !ok {
|
||||
if !ok { //升级失败,说明是tcp连接
|
||||
s.handleTcp(c)
|
||||
return gnet.None
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user