user_singlematch.go 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. package gatesink
  2. import (
  3. "bet24.com/log"
  4. singlematch "bet24.com/servers/micros/matches/proto"
  5. "encoding/json"
  6. "strconv"
  7. )
  8. func (this *user) onSingleMatchMsg(msg, data string) {
  9. switch msg {
  10. case "createSingleMatch":
  11. this.createSingleMatch(msg, data)
  12. case "getMySingleMatch":
  13. this.getMySingleMatch(msg, data)
  14. case "getSingleMatchList":
  15. this.getSingleMatchList(msg, data)
  16. case "SingleMatchListRevive":
  17. this.singleMatchListRevive(msg, data)
  18. }
  19. }
  20. func (this *user) createSingleMatch(msg, data string) {
  21. matchId, err := strconv.Atoi(data)
  22. if err != nil {
  23. log.Release("gatesink.createSingleMatch %v", err)
  24. this.WriteMsg(msg, "invalid argument")
  25. return
  26. }
  27. var ret singlematch.SingleMatch_resp
  28. ret.ErrorMsg, ret.MatchData = singlematch.CreateUserSingleMatch(this.getUserId(), matchId)
  29. d, _ := json.Marshal(ret)
  30. this.WriteMsg(msg, string(d))
  31. }
  32. func (this *user) getMySingleMatch(msg, data string) {
  33. matchInfo := singlematch.GetUserSingleMatch(this.getUserId())
  34. d, _ := json.Marshal(matchInfo)
  35. this.WriteMsg(msg, string(d))
  36. }
  37. func (this *user) singleMatchListRevive(msg, data string) {
  38. ok := singlematch.SingleMatchRevive(this.getUserId(), data != "")
  39. if ok {
  40. this.WriteMsg(msg, "ok")
  41. return
  42. }
  43. this.WriteMsg(msg, "fail")
  44. }
  45. func (this *user) getSingleMatchList(msg, data string) {
  46. this.WriteMsg(msg, singlematch.GetSingleMatchList())
  47. }