- 简化 ClientData 结构体,移除不必要的方法 - 优化 Player 结构体,调整 Conn 类型 - 更新 wscodec.go 中的 Conn 结构体 - 删除未使用的 XML 相关文件和代码 - 调整 ServerEvent 和 controller 中的相关逻辑
31 lines
480 B
Go
31 lines
480 B
Go
package socket
|
|
|
|
func ConutPlayer() int {
|
|
|
|
count := 0
|
|
Mainplayer.Range(func(uint32, *Player) bool {
|
|
count++
|
|
return true // 继续遍历
|
|
})
|
|
return count
|
|
}
|
|
|
|
type ClientData struct {
|
|
IsCrossDomain bool //是否跨域过
|
|
Player *Player //客户实体
|
|
//UserID uint32
|
|
|
|
Wsmsg *WsCodec
|
|
}
|
|
|
|
func NewClientData() *ClientData {
|
|
cd := ClientData{
|
|
IsCrossDomain: false,
|
|
Player: nil,
|
|
|
|
Wsmsg: &WsCodec{},
|
|
}
|
|
return &cd
|
|
|
|
}
|