global.go 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. //@File global.go
  2. //@Time 2022/05/12
  3. //@Author #Suyghur,
  4. package ext
  5. import (
  6. "github.com/liyue201/gostl/ds/map"
  7. "ylink/comm/model"
  8. )
  9. var (
  10. // GameVipMap vip玩家信息(GameId,*PlayerInfoMap)
  11. GameVipMap *treemap.Map
  12. // CsInfoMap 客服信息(CsId,*CsInfo)
  13. CsInfoMap *treemap.Map
  14. // GameOnlinePlayerMap 在线玩家信息
  15. GameOnlinePlayerMap *treemap.Map
  16. // GameConnectedMap 已连接客服玩家
  17. GameConnectedMap *treemap.Map
  18. // WaitingQueue 玩家等待队列
  19. WaitingQueue *treemap.Map
  20. )
  21. func GetVipPlayer(gameId, playerId string) *model.PlayerInfo {
  22. if GameVipMap.Contains(gameId) {
  23. playerInfoMap := GameVipMap.Get(gameId).(*treemap.Map)
  24. if playerInfoMap.Contains(playerId) {
  25. return playerInfoMap.Get(playerId).(*model.PlayerInfo)
  26. }
  27. }
  28. return nil
  29. }
  30. func GetCsInfo(csId string) *model.CsInfo {
  31. if CsInfoMap.Contains(csId) {
  32. return CsInfoMap.Get(csId).(*model.CsInfo)
  33. }
  34. return nil
  35. }
  36. func GetConnectedPlayerInfo(gameId, playerId string) *model.PlayerInfo {
  37. if GameConnectedMap.Contains(gameId) {
  38. connectedMap := GameConnectedMap.Get(gameId).(*treemap.Map)
  39. if connectedMap.Contains(playerId) {
  40. return connectedMap.Get(playerId).(*model.PlayerInfo)
  41. }
  42. }
  43. return nil
  44. }
  45. func RemoveConnectedPlayerInfo(gameId, playerId string) {
  46. if GameConnectedMap.Contains(gameId) {
  47. connectedMap := GameConnectedMap.Get(gameId).(*treemap.Map)
  48. if connectedMap.Contains(playerId) {
  49. connectedMap.Erase(playerId)
  50. }
  51. }
  52. }
  53. func GetOnlinePlayerInfo(gameId, playerId string) *model.PlayerInfo {
  54. if GameOnlinePlayerMap.Contains(gameId) {
  55. onlinePlayerMap := GameOnlinePlayerMap.Get(gameId).(*treemap.Map)
  56. if onlinePlayerMap.Contains(playerId) {
  57. return onlinePlayerMap.Get(playerId).(*model.PlayerInfo)
  58. }
  59. }
  60. return nil
  61. }