playerdisconnectlogic.go 764 B

12345678910111213141516171819202122232425262728293031323334
  1. package logic
  2. import (
  3. "context"
  4. "ylink/comm/ctxdata"
  5. "ylink/core/cmd/rpc/cmd"
  6. "github.com/zeromicro/go-zero/core/logx"
  7. "ylink/bff/cmdbff/api/internal/svc"
  8. )
  9. type PlayerDisconnectLogic struct {
  10. logx.Logger
  11. ctx context.Context
  12. svcCtx *svc.ServiceContext
  13. }
  14. func NewPlayerDisconnectLogic(ctx context.Context, svcCtx *svc.ServiceContext) *PlayerDisconnectLogic {
  15. return &PlayerDisconnectLogic{
  16. Logger: logx.WithContext(ctx),
  17. ctx: ctx,
  18. svcCtx: svcCtx,
  19. }
  20. }
  21. func (l *PlayerDisconnectLogic) PlayerDisconnect() error {
  22. gameId := ctxdata.GetGameIdFromCtx(l.ctx)
  23. playerId := ctxdata.GetPlayerIdFromCtx(l.ctx)
  24. _, err := l.svcCtx.CmdRpc.PlayerDisconnect(l.ctx, &cmd.PlayerDisconnectReq{
  25. GameId: gameId,
  26. PlayerId: playerId,
  27. })
  28. return err
  29. }