Documentation ¶
Index ¶
- Constants
- Variables
- func SendHandle(p *PlayerGame, kcpMsg *alg.PackMsg)
- type GateServer
- type HandlerFunc
- type KcpEvent
- type NodeService
- type PlayerGame
- func (p *PlayerGame) ApplyFriendCsReq(tcpMsg *alg.PackMsg)
- func (p *PlayerGame) GateToGame(tcpMsg *alg.PackMsg)
- func (p *PlayerGame) GateToPlayer(cmdId uint16, playerMsg pb.Message)
- func (p *PlayerGame) HandleFriendCsReq(tcpMsg *alg.PackMsg)
- func (p *PlayerGame) HandlePlayerHeartBeatCsReq(tcpMsg *alg.PackMsg)
- func (p *PlayerGame) PlayerLogoutCsReq(tcpMsg *alg.PackMsg)
- func (p *PlayerGame) PlayerRegisterMessage(cmdId uint16, tcpMsg *alg.PackMsg)
- func (p *PlayerGame) SendMsgCsReq(tcpMsg *alg.PackMsg)
- type RouteManager
- type Store
- func (s *Store) DistLockSync(accountId string) bool
- func (s *Store) DistUnlock(accountId string)
- func (s *Store) DistUnlockPlayerStatus(accountId string)
- func (s *Store) GetComboTokenByAccountId(accountId string) string
- func (s *Store) GetPlayerStatus(accountId string) ([]byte, bool)
- func (s *Store) GetPlayerUidByAccountId(AccountId uint32) *database.PlayerUid
- func (s *Store) UpdatePlayerUid(AccountId uint32) *database.PlayerUid
Constants ¶
View Source
const ( MaxLockAliveTime = 10000 // 单个锁的最大存活时间 毫秒 LockRetryWaitTime = 50 // 同步加锁重试间隔时间 毫秒 MaxLockRetryTimes = 2 // 同步加锁最大重试次数 )
View Source
const ( PacketMaxLen = 343 * 1024 // 最大应用层包长度 KcpConnAddrChangeNotify = "KcpConnAddrChangeNotify" )
Variables ¶
View Source
var CLIENT_CONN_NUM int32 = 0 // 当前客户端连接数
View Source
var QPS int64
Functions ¶
Types ¶
type GateServer ¶
type GateServer struct { AppId uint32 WorkerId int64 Port string InnerAddr string OuterAddr string Config *config.Config Store *Store Ec2b *random.Ec2b Ticker *time.Ticker Stop chan struct{} // contains filtered or unexported fields }
func (*GateServer) Close ¶ added in v1.2.1
func (s *GateServer) Close() error
func (*GateServer) GlobalRotationEvent5s ¶ added in v1.2.1
func (s *GateServer) GlobalRotationEvent5s()
func (*GateServer) NewGame ¶
func (s *GateServer) NewGame(kcpConn *kcp.UDPSession) *PlayerGame
func (*GateServer) PlayerGetTokenCsReq ¶ added in v1.0.5
func (s *GateServer) PlayerGetTokenCsReq(p *PlayerGame, playerMsg []byte)
func (*GateServer) RunKcp ¶ added in v1.2.1
func (s *GateServer) RunKcp() error
type HandlerFunc ¶ added in v1.2.1
type NodeService ¶ added in v1.2.1
type NodeService struct {
// contains filtered or unexported fields
}
func (*NodeService) GateToNodePingReq ¶ added in v1.2.2
func (n *NodeService) GateToNodePingReq()
func (*NodeService) GateToNodePingRsp ¶ added in v1.2.2
func (n *NodeService) GateToNodePingRsp(serviceMsg pb.Message)
func (*NodeService) ServiceConnectionReq ¶ added in v1.2.1
func (n *NodeService) ServiceConnectionReq()
向node注册
func (*NodeService) ServiceConnectionRsp ¶ added in v1.2.1
func (n *NodeService) ServiceConnectionRsp(serviceMsg pb.Message)
type PlayerGame ¶
type PlayerGame struct { Status spb.PlayerStatus Uid uint32 // uid AccountId uint32 Seed uint64 XorKey []byte // 密钥 KcpConn *kcp.UDPSession LastActiveTime uint64 // 最近一次的活跃时间 RouteManager *RouteManager // contains filtered or unexported fields }
func (*PlayerGame) ApplyFriendCsReq ¶ added in v1.2.2
func (p *PlayerGame) ApplyFriendCsReq(tcpMsg *alg.PackMsg)
func (*PlayerGame) GateToPlayer ¶ added in v1.2.1
func (p *PlayerGame) GateToPlayer(cmdId uint16, playerMsg pb.Message)
将消息发送给客户端
func (*PlayerGame) HandleFriendCsReq ¶ added in v1.2.2
func (p *PlayerGame) HandleFriendCsReq(tcpMsg *alg.PackMsg)
func (*PlayerGame) HandlePlayerHeartBeatCsReq ¶
func (p *PlayerGame) HandlePlayerHeartBeatCsReq(tcpMsg *alg.PackMsg)
玩家ping包处理
func (*PlayerGame) PlayerLogoutCsReq ¶ added in v1.2.1
func (p *PlayerGame) PlayerLogoutCsReq(tcpMsg *alg.PackMsg)
玩家主动离线处理
func (*PlayerGame) PlayerRegisterMessage ¶
func (p *PlayerGame) PlayerRegisterMessage(cmdId uint16, tcpMsg *alg.PackMsg)
func (*PlayerGame) SendMsgCsReq ¶ added in v1.2.2
func (p *PlayerGame) SendMsgCsReq(tcpMsg *alg.PackMsg)
type RouteManager ¶ added in v1.2.1
type RouteManager struct {
// contains filtered or unexported fields
}
func NewRouteManager ¶ added in v1.2.1
func NewRouteManager(p *PlayerGame) (r *RouteManager)
type Store ¶
type Store struct { PlayerUidMysql *gorm.DB LoginRedis *redis.Client StatusRedis *redis.Client // contains filtered or unexported fields }
func (*Store) DistLockSync ¶ added in v1.0.5
DistLockSync 加锁同步阻塞直到成功或超时
func (*Store) DistUnlock ¶ added in v1.0.5
DistUnlock 解锁
func (*Store) DistUnlockPlayerStatus ¶ added in v1.2.1
删除玩家状态
func (*Store) GetComboTokenByAccountId ¶ added in v1.0.5
根据accounid拉取combotoken
func (*Store) GetPlayerStatus ¶ added in v1.0.5
获取玩家状态
func (*Store) GetPlayerUidByAccountId ¶ added in v1.0.5
使用account id拉取数据
Click to show internal directories.
Click to hide internal directories.