fix(socket): 修复连接处理逻辑并优化数据解码流程

- 修复 `OnOpen` 中网络类型判断位置不正确的问题,提前过滤非 TCP 连接
- 移除 `OnTraffic` 中重复的网络类型判断
- 优化 `TomeeSocketCodec` 的解码逻辑,使用 `InboundBuffered` 和 `Next` 提高效率
- 调整 `ByteArray` 创建方法参数,避免可变参数带来的性能损耗
- 在 `ClientData` 中将 `IsCrossDomain` 改为 `sync.Once` 避免重复处理
- 使用 `AsyncWrite` 替代 `Write` 提升写入异步性
- 修复连接关闭流程,使用
This commit is contained in:
2025-11-01 14:31:19 +08:00
parent 008701d3de
commit ea4ca98e49
11 changed files with 60 additions and 92 deletions

View File

@@ -56,7 +56,7 @@ func (h *ServerHandler) RegisterLogic(ctx context.Context, id, port uint16) erro
}
t, _ := blservice.NewLoginServiceService().GetServerID(id)
aa, ok := clientmap[t]
if ok { //如果已经存在且这个端口已经被存过
if ok && aa != nil { //如果已经存在且这个端口已经被存过
aa.QuitSelf(0)
}
clientmap[port] = &revClient