aozhiwei dd868a958f 1
2024-03-11 16:39:08 +08:00

127 lines
2.5 KiB
Go

package player
import (
"cs"
"f5"
"github.com/golang/protobuf/proto"
"main/common"
. "main/global"
)
type player struct {
cs.MsgHandlerImpl
socket f5.WspCliConn
accountId string
sessionId string
zoneId int32
nodeId int32
name string
avatarUrl string
heroId string
headFrame string
ping int32
team common.Team
}
func (this *player) SendMsg(rspMsg proto.Message) {
if this.socket.IsValid() {
GetWspListener().SendProxyMsg(this.socket.Conn, this.socket.SocketHandle, rspMsg)
}
}
func (this *player) init(req *pendingLoginRequest, name string, avatarUrl string, heroId string,
headFrame string){
this.socket = req.hdr.GetSocket()
this.accountId = req.msg.GetAccountId()
this.sessionId = req.msg.GetSessionId()
this.zoneId = req.msg.GetZoneId()
this.nodeId = req.msg.GetNodeId()
this.name = name
this.avatarUrl = avatarUrl
this.heroId = heroId
this.headFrame = headFrame
}
func (this *player) againInit(req *pendingLoginRequest, name string, avatarUrl string, heroId string,
headFrame string){
this.socket = req.hdr.GetSocket()
this.accountId = req.msg.GetAccountId()
this.sessionId = req.msg.GetSessionId()
this.zoneId = req.msg.GetZoneId()
this.nodeId = req.msg.GetNodeId()
this.name = name
this.avatarUrl = avatarUrl
this.heroId = heroId
this.headFrame = headFrame
}
func (this *player) GetSocket() f5.WspCliConn {
return this.socket
}
func (this *player) onOffline(){
this.socket.Reset()
}
func (this *player) reBind(socket f5.WspCliConn) {
if this.socket.IsValid() {
delete(_playerMgr.socketHash, this.socket)
}
this.socket = socket
_playerMgr.socketHash[this.socket] = this
}
func (this *player) GetAccountId() string {
return this.accountId
}
func (this *player) GetSessionId() string {
return this.sessionId
}
func (this *player) GetName() string {
return this.name
}
func (this *player) GetAvatarUrl() string {
return this.avatarUrl
}
func (this *player) GetHeroId() string {
return this.heroId
}
func (this *player) GetHeadFrame() string {
return this.headFrame
}
func (this *player) GetPing() int32 {
return this.ping
}
func (this *player) GetZoneId() int32 {
return this.zoneId
}
func (this *player) GetNodeId() int32 {
return this.nodeId
}
func (this *player) IsOnline() bool {
return this.socket.IsValid()
}
func (this *player) internalSetPing(ping int32) {
if ping < 30 {
this.ping = 30
} else if ping > 1000 {
this.ping = 1000
} else {
this.ping = ping
}
}
func (this *player) GetTeam() common.Team {
return this.team
}