csconnectplayerlogic.go 833 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. package logic
  2. import (
  3. "context"
  4. "ylink/comm/ctxdata"
  5. "ylink/core/cmd/rpc/cmd"
  6. "ylink/bff/cmdbff/api/internal/svc"
  7. "ylink/bff/cmdbff/api/internal/types"
  8. "github.com/zeromicro/go-zero/core/logx"
  9. )
  10. type CsConnectPlayerLogic struct {
  11. logx.Logger
  12. ctx context.Context
  13. svcCtx *svc.ServiceContext
  14. }
  15. func NewCsConnectPlayerLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CsConnectPlayerLogic {
  16. return &CsConnectPlayerLogic{
  17. Logger: logx.WithContext(ctx),
  18. ctx: ctx,
  19. svcCtx: svcCtx,
  20. }
  21. }
  22. func (l *CsConnectPlayerLogic) CsConnectPlayer(req *types.CsConnectPlayerReq) error {
  23. csId := ctxdata.GetCsIdFromCtx(l.ctx)
  24. _, err := l.svcCtx.CmdRpc.CsConnectPlayer(l.ctx, &cmd.CsConnectPlayerReq{
  25. CsId: csId,
  26. PlayerId: req.PlayerId,
  27. GameId: req.GameId,
  28. })
  29. if err != nil {
  30. return err
  31. }
  32. return nil
  33. }