csfetchplayerqueuelogic.go 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. package logic
  2. import (
  3. "context"
  4. "github.com/pkg/errors"
  5. "google.golang.org/protobuf/types/known/structpb"
  6. "ylink/comm/result"
  7. "ylink/core/inner/rpc/internal/svc"
  8. "ylink/core/inner/rpc/pb"
  9. "github.com/zeromicro/go-zero/core/logx"
  10. )
  11. type CsFetchPlayerQueueLogic struct {
  12. ctx context.Context
  13. svcCtx *svc.ServiceContext
  14. logx.Logger
  15. }
  16. func NewCsFetchPlayerQueueLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CsFetchPlayerQueueLogic {
  17. return &CsFetchPlayerQueueLogic{
  18. ctx: ctx,
  19. svcCtx: svcCtx,
  20. Logger: logx.WithContext(ctx),
  21. }
  22. }
  23. func (l *CsFetchPlayerQueueLogic) CsFetchPlayerQueue(in *pb.InnerCsFetchPlayerQueueReq) (*pb.InnerCsFetchPlayerQueueResp, error) {
  24. // todo: 查询等待用户的队列
  25. list, err := structpb.NewList([]interface{}{
  26. map[string]interface{}{
  27. "player_id": "player1111",
  28. "game_id": "game1231",
  29. "wait_time": 1000,
  30. },
  31. map[string]interface{}{
  32. "player_id": "player2222",
  33. "game_id": "game1231",
  34. "wait_time": 10,
  35. },
  36. })
  37. if err != nil {
  38. return nil, errors.Wrap(result.NewErrMsg("fetch player wait queue error"), "")
  39. }
  40. return &pb.InnerCsFetchPlayerQueueResp{
  41. List: list,
  42. }, nil
  43. }