playerdisconnectlogic.go 848 B

123456789101112131415161718192021222324252627282930313233343536
  1. package logic
  2. import (
  3. "context"
  4. "ylink/core/cmd/rpc/internal/svc"
  5. "ylink/core/cmd/rpc/pb"
  6. "ylink/core/inner/rpc/inner"
  7. "github.com/zeromicro/go-zero/core/logx"
  8. )
  9. type PlayerDisconnectLogic struct {
  10. ctx context.Context
  11. svcCtx *svc.ServiceContext
  12. logx.Logger
  13. }
  14. func NewPlayerDisconnectLogic(ctx context.Context, svcCtx *svc.ServiceContext) *PlayerDisconnectLogic {
  15. return &PlayerDisconnectLogic{
  16. ctx: ctx,
  17. svcCtx: svcCtx,
  18. Logger: logx.WithContext(ctx),
  19. }
  20. }
  21. func (l *PlayerDisconnectLogic) PlayerDisconnect(in *pb.PlayerDisconnectReq) (*pb.PlayerDisconnectResp, error) {
  22. // 调用inner服务玩家状态
  23. _, err := l.svcCtx.InnerRpc.PlayerDisconnect(l.ctx, &inner.InnerPlayerDisconnectReq{
  24. PlayerId: in.PlayerId,
  25. GameId: in.GameId,
  26. })
  27. if err != nil {
  28. return nil, err
  29. }
  30. return &pb.PlayerDisconnectResp{}, nil
  31. }