pointmatchnotification.go 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. package pointmatch
  2. import (
  3. "bet24.com/log"
  4. "bet24.com/servers/micros/matches/handler/matchbase"
  5. notification "bet24.com/servers/micros/notification/proto"
  6. "encoding/json"
  7. )
  8. func postUserEnterNotification(userId int, matchNo int, nickname string, faceId int, faceUrl string) {
  9. mi := getMatchManager().getMatch(matchNo)
  10. if mi == nil {
  11. log.Release("postUserEnterNotification matchNo[%d] not found", matchNo)
  12. return
  13. }
  14. // 发送给所有人
  15. ni := matchbase.Match_notificationInfo{Msg: matchbase.Match_noti_userenter, UserId: userId,
  16. FaceId: faceId, NickName: nickname, FaceUrl: faceUrl}
  17. d, _ := json.Marshal(ni)
  18. mi.sendNotification(-1, string(d))
  19. }
  20. func postUserExitNotification(userId int, matchNo int) {
  21. mi := getMatchManager().getMatch(matchNo)
  22. if mi == nil {
  23. log.Release("postUserExitNotification matchNo[%d] not found", matchNo)
  24. return
  25. }
  26. // 发送给所有人
  27. ni := matchbase.Match_notificationInfo{Msg: matchbase.Match_noti_userexit, UserId: userId}
  28. d, _ := json.Marshal(ni)
  29. mi.sendNotification(-1, string(d))
  30. // 发给自己
  31. notification.AddNotification(userId, notification.Notification_Match, string(d))
  32. }
  33. func postMatchStatusChangedNotificaiton(matchNo int, oldStatus, newStatus int) {
  34. mi := getMatchManager().getMatch(matchNo)
  35. if mi == nil {
  36. log.Release("postMatchStatusChangedNotificaiton matchNo[%d] not found", matchNo)
  37. return
  38. }
  39. // 发送给所有人
  40. ni := matchbase.Match_notificationInfo{Msg: matchbase.Match_noti_statuschanged, OldStatus: oldStatus, NewStatus: newStatus}
  41. d, _ := json.Marshal(ni)
  42. mi.sendNotification(-1, string(d))
  43. }
  44. func postUserScoreChangedNotification(userId int, matchNo int, score int) {
  45. mi := getMatchManager().getMatch(matchNo)
  46. if mi == nil {
  47. log.Release("postUserScoreChangedNotification matchNo[%d] not found", matchNo)
  48. return
  49. }
  50. // 发送给所有人
  51. ni := matchbase.Match_notificationInfo{Msg: matchbase.Match_noti_scorechanged, UserId: userId, Score: score}
  52. d, _ := json.Marshal(ni)
  53. mi.sendNotification(-1, string(d))
  54. }
  55. func postUserPromotionNotification(userId int, matchNo int) {
  56. mi := getMatchManager().getMatch(matchNo)
  57. if mi == nil {
  58. log.Release("postUserPromotionNotification matchNo[%d] not found", matchNo)
  59. return
  60. }
  61. // 发送给所有人
  62. ni := matchbase.Match_notificationInfo{Msg: matchbase.Match_noti_promoted}
  63. d, _ := json.Marshal(ni)
  64. mi.sendNotification(userId, string(d))
  65. }
  66. func postUserEliminationNotification(userId int, matchNo int, rank int) {
  67. mi := getMatchManager().getMatch(matchNo)
  68. if mi == nil {
  69. log.Release("postUserEliminationNotification matchNo[%d] not found", matchNo)
  70. return
  71. }
  72. // 发送给所有人
  73. ni := matchbase.Match_notificationInfo{Msg: matchbase.Match_noti_eliminated, Rank: rank}
  74. d, _ := json.Marshal(ni)
  75. mi.sendNotification(userId, string(d))
  76. }
  77. func postUserRankNotification(userId int, matchNo int, rank int, prize int) {
  78. mi := getMatchManager().getMatch(matchNo)
  79. if mi == nil {
  80. log.Release("postUserRankNotification matchNo[%d] not found", matchNo)
  81. return
  82. }
  83. // 发送给所有人
  84. ni := matchbase.Match_notificationInfo{Msg: matchbase.Match_noti_rank, Rank: rank, Prize: prize}
  85. d, _ := json.Marshal(ni)
  86. mi.sendNotification(userId, string(d))
  87. }
  88. func postUserMatchRoomNotification(userId int, matchNo int, serverAddr string, tableId, chairId int) {
  89. mi := getMatchManager().getMatch(matchNo)
  90. if mi == nil {
  91. log.Release("postUserMatchRoomNotification matchNo[%d] not found", matchNo)
  92. return
  93. }
  94. // 发送给所有人
  95. ni := matchbase.Match_notificationInfo{Msg: matchbase.Match_noti_matchroom, ServerAddr: serverAddr, TableId: tableId, ChairId: chairId}
  96. d, _ := json.Marshal(ni)
  97. mi.sendNotification(userId, string(d))
  98. }