C2G_BattleNotifyHandler.cs 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. using System;
  2. using System.Text.Json;
  3. namespace ET.Server
  4. {
  5. /// <summary>
  6. /// 游戏开始
  7. /// </summary>
  8. [MessageHandler(SceneType.Game)]
  9. public class C2G_BattleNotifyHandler : AMRpcHandler<C2G_BattleNotify, G2C_BattleNotify>
  10. {
  11. protected override async ETTask Run(Session session, C2G_BattleNotify request, G2C_BattleNotify response, Action reply)
  12. {
  13. WNPlayer player = session.GetComponent<SessionPlayerComponent>().GetMyPlayer();
  14. if (player == null)
  15. {
  16. Log.Debug($"操作错误, player is null");
  17. response.Error = ErrorCode.ERR_OperationError;
  18. reply();
  19. return;
  20. }
  21. // 判断参数
  22. if (string.IsNullOrEmpty(request.Message))
  23. {
  24. Log.Debug($"参数错误, request.NameType={request.Message}");
  25. response.Error = ErrorCode.ERR_ParameterError;
  26. reply();
  27. return;
  28. }
  29. // 通知战斗服
  30. Struct.TriggerEventNotify notifyMsg = new Struct.TriggerEventNotify();
  31. notifyMsg.message = request.Message;
  32. player.GetXmdsManager().notifyBattleServer(player.Map.Id.ToString(), NotifyBSName.TriggerEvent, JsonSerializer.Serialize(notifyMsg));
  33. reply();
  34. await ETTask.CompletedTask;
  35. }
  36. }
  37. }