matchnotification.go 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. package simplematch
  2. import (
  3. "bet24.com/servers/micros/matches/handler/matchbase"
  4. notification "bet24.com/servers/micros/notification/proto"
  5. "encoding/json"
  6. )
  7. func (mi *matchinstance) postUserEnterNotification(userId int, nickname string, faceId int, faceUrl string, score int) {
  8. // 发送给所有人
  9. ni := matchbase.Match_notificationInfo{Msg: matchbase.Match_noti_userenter, UserId: userId,
  10. FaceId: faceId, NickName: nickname, FaceUrl: faceUrl, Score: score}
  11. d, _ := json.Marshal(ni)
  12. mi.sendNotification(-1, string(d))
  13. }
  14. func (mi *matchinstance) postUserExitNotification(userId int) {
  15. // 发送给所有人
  16. ni := matchbase.Match_notificationInfo{Msg: matchbase.Match_noti_userexit, UserId: userId}
  17. d, _ := json.Marshal(ni)
  18. mi.sendNotification(-1, string(d))
  19. // 发给自己
  20. notification.AddNotification(userId, notification.Notification_Match, string(d))
  21. }
  22. func (mi *matchinstance) postMatchStatusChangedNotificaiton(oldStatus, newStatus int) {
  23. // 发送给所有人
  24. ni := matchbase.Match_notificationInfo{Msg: matchbase.Match_noti_statuschanged, OldStatus: oldStatus, NewStatus: newStatus}
  25. d, _ := json.Marshal(ni)
  26. mi.sendNotification(-1, string(d))
  27. }
  28. func (mi *matchinstance) postUserScoreChangedNotification(userId int, score int) {
  29. // 发送给所有人
  30. ni := matchbase.Match_notificationInfo{Msg: matchbase.Match_noti_scorechanged, UserId: userId, Score: score}
  31. d, _ := json.Marshal(ni)
  32. mi.sendNotification(-1, string(d))
  33. }
  34. func (mi *matchinstance) postUserPromotionNotification(userId int) {
  35. // 发送给所有人
  36. ni := matchbase.Match_notificationInfo{Msg: matchbase.Match_noti_promoted}
  37. d, _ := json.Marshal(ni)
  38. mi.sendNotification(userId, string(d))
  39. }
  40. func (mi *matchinstance) postUserEliminationNotification(userId int, rank int) {
  41. // 发送给所有人
  42. ni := matchbase.Match_notificationInfo{Msg: matchbase.Match_noti_eliminated, Rank: rank}
  43. d, _ := json.Marshal(ni)
  44. mi.sendNotification(userId, string(d))
  45. }
  46. func (mi *matchinstance) postUserRankNotification(userId int, rank int, prize int) {
  47. // 发送给所有人
  48. ni := matchbase.Match_notificationInfo{Msg: matchbase.Match_noti_rank, Rank: rank, Prize: prize}
  49. d, _ := json.Marshal(ni)
  50. mi.sendNotification(userId, string(d))
  51. }
  52. func (mi *matchinstance) postUserMatchRoomNotification(userId int, serverAddr string, tableId, chairId int) {
  53. // 发送给所有人
  54. ni := matchbase.Match_notificationInfo{Msg: matchbase.Match_noti_matchroom, ServerAddr: serverAddr, TableId: tableId, ChairId: chairId}
  55. d, _ := json.Marshal(ni)
  56. mi.sendNotification(userId, string(d))
  57. }