global.go 1.8 KB

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