| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- package sessions
- import (
- "sync/atomic"
- cproto "github.com/cherry-game/cherry/net/proto"
- )
- func GetSession(playerID int64) (*cproto.Session, bool) {
- value, found := actor.GetCacheSession(playerID)
- if found {
- return value, true
- }
- if !actor.isSync {
- return actor.GetRedisSession(playerID)
- }
- return nil, false
- }
- func UIDCount() int64 {
- return atomic.LoadInt64(&actor.count)
- }
- func GetAgentPathWithPlayerIDS(playerIDList []int64) map[string][]int64 {
- sessionMaps, missPlayerIDS := actor.GetCacheSessions(playerIDList)
- // 未命中的playerID从redis再查一次
- if !actor.isSync && len(missPlayerIDS) > 0 {
- sessionMap := actor.GetRedisSessions(missPlayerIDS)
- for playerID, session := range sessionMap {
- sessionMaps[playerID] = session
- }
- }
- agentPathUIDMaps := map[string][]int64{}
- for _, session := range sessionMaps {
- if len(session.AgentPath) > 0 && session.Uid > 0 {
- agentPathUIDMaps[session.AgentPath] = append(agentPathUIDMaps[session.AgentPath], session.Uid)
- }
- }
- return agentPathUIDMaps
- }
|