user_gameroom.go 959 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. package gatesink
  2. import (
  3. "encoding/json"
  4. "fmt"
  5. "strings"
  6. _ "bet24.com/log"
  7. "bet24.com/redis"
  8. )
  9. type gameRoom struct {
  10. Name string
  11. Online string
  12. PrizePool string
  13. }
  14. func (this *user) getGameRooms(msg, data string) {
  15. id := Sink.GetVersionID()
  16. retData := ""
  17. addrKey := fmt.Sprintf("Addr%d", id)
  18. onlineKey := fmt.Sprintf("Online%d", id)
  19. if Sink.IsChipRoom() {
  20. addrKey = "ChipAddr"
  21. onlineKey = "ChipOnline"
  22. }
  23. keys := redis.Key_GetKeys(fmt.Sprintf("%s:%s:*", data, addrKey))
  24. if len(keys) > 0 {
  25. var rooms []gameRoom
  26. for _, v := range keys {
  27. name, ok := redis.String_Get(v)
  28. if ok {
  29. var room gameRoom
  30. room.Name = name
  31. room.Online, ok = redis.String_Get(strings.Replace(v, addrKey, onlineKey, -1))
  32. rooms = append(rooms, room)
  33. }
  34. }
  35. d, _ := json.Marshal(rooms)
  36. retData = string(d)
  37. }
  38. this.WriteMsg(msg, retData)
  39. }
  40. func (this *user) getLonghuRooms(msg, data string) {
  41. this.getGameRooms(msg, "longhu")
  42. }