remotemessage.go 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. package proto
  2. import (
  3. "bet24.com/log"
  4. "bet24.com/servers/micros/common"
  5. "context"
  6. )
  7. const (
  8. DeviceType_Android = iota
  9. DeviceType_IOS
  10. )
  11. type UserToken struct {
  12. UserId int
  13. DeviceType int
  14. Token string
  15. }
  16. func SetUserToken(userId int, deviceType int, token string) {
  17. xclient := getClient()
  18. args := &Request{
  19. UserId: userId,
  20. DeviceType: deviceType,
  21. Token: token,
  22. }
  23. reply := &Response{}
  24. err := xclient.Call(context.Background(), "SetUserToken", args, reply)
  25. if err != nil {
  26. log.Debug("remotemessage.SetUserToken failed to call: %v", err)
  27. common.GetClientPool().RemoveClient(ServiceName)
  28. }
  29. }
  30. func SendRemoteMessage(userIds []int, title string, content string) {
  31. xclient := getClient()
  32. args := &Request{
  33. UserIds: userIds,
  34. Title: title,
  35. Content: content,
  36. }
  37. reply := &Response{}
  38. err := xclient.Call(context.Background(), "SendRemoteMessage", args, reply)
  39. if err != nil {
  40. log.Debug("remotemessage.SendRemoteMessage failed to call: %v", err)
  41. common.GetClientPool().RemoveClient(ServiceName)
  42. }
  43. }