Files
bl/logic/service/player/server.go
昔念 32f57732fe ```
refactor(common/cool/coolconfig): 修改RPC配置字段类型

将RPC字段从uint16类型更改为string类型的Address字段,
以支持更灵活的地址配置。同时更新了配置初始化逻辑,
从server.rpc改为server.address作为配置键。
```
2026-01-25 03:40:29 +08:00

44 lines
842 B
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package player
import (
"github.com/panjf2000/gnet/v2"
)
func GetPlayer(c gnet.Conn, userid uint32) *Player { //TODO 这里待优化,可能存在内存泄漏问题
//检查player初始化是否为conn初始后取map防止二次连接后存在两个player
clientdata, ok := c.Context().(*ClientData)
if !ok {
return nil
}
if clientdata.Player == nil {
clientdata.Player = NewPlayer(
WithConn(c), //注入conn
)
}
// gff := socket.NewClientData()
// gff.Player = clientdata.Player
// c.MainConn.SetContext(gff)
Mainplayer.Store(userid, clientdata.Player)
return clientdata.Player
// return nil
}
func KickPlayer(userid uint32) error { //踢出玩家
//TODO 返回错误码
//var player *entity.Player
if player1, ok := Mainplayer.Load(userid); ok {
player1.Kick(0)
}
//return player
return nil
}