"refactor(network): 重构连接处理逻辑,使用自定义Conn类型替代gnet.Conn依赖"
This commit is contained in:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user