notify.go 881 B

123456789101112131415161718192021222324252627282930313233
  1. package dao
  2. import (
  3. "context"
  4. "net/url"
  5. "strconv"
  6. "go-common/library/ecode"
  7. "go-common/library/log"
  8. )
  9. // NotifyGame to notify game.
  10. func (d *Dao) NotifyGame(c context.Context, mid int64, accessToken, action string) (err error) {
  11. params := url.Values{}
  12. params.Set("modifiedAttr", action)
  13. params.Set("mid", strconv.FormatInt(mid, 10))
  14. if accessToken != "" {
  15. params.Set("access_token", accessToken)
  16. }
  17. params.Set("from", "passport-game-cloud-job")
  18. var res struct {
  19. Code int `json:"code"`
  20. }
  21. if err = d.gameClient.Get(c, d.delGameCacheURI, "127.0.0.1", params, &res); err != nil {
  22. log.Error("failed to notify game, d.gameClient.Get(%s) error(%v)", d.delGameCacheURI+"?"+params.Encode(), err)
  23. return
  24. }
  25. if res.Code != 0 {
  26. err = ecode.Int(res.Code)
  27. log.Error("failed to notify game, url(%s) err(%v)", d.delGameCacheURI+"?"+params.Encode(), err)
  28. }
  29. return
  30. }