"refactor(network): 重构连接处理逻辑,使用自定义Conn类型替代gnet.Conn依赖"

This commit is contained in:
1
2025-07-26 02:14:54 +00:00
parent 99318f6674
commit 459a779591
5 changed files with 17 additions and 27 deletions

View File

@@ -1,13 +1,10 @@
package entity
import (
"context"
"fmt"
"sync"
"time"
"github.com/panjf2000/gnet/v2"
)
type Player struct {
@@ -28,9 +25,9 @@ func WithUserID(userID uint32) PlayerOption {
p.UserID = userID
}
}
func WithConn(c gnet.Conn) PlayerOption {
func WithConn(c Conn) PlayerOption {
return func(p *Player) {
p.MainConn = Conn{MainConn: c}
p.MainConn = c
}
}
@@ -54,8 +51,6 @@ func (p *Player) SendPack(b []byte) error {
return err
}
// IsLoggedIn 检查是否已登录
func (lw *Player) IsLoggedIn() bool {
lw.mu.Lock()