using System; using System.Text.Json; namespace ET.Server { /// /// 游戏开始 /// [MessageHandler(SceneType.Game)] public class C2G_BattleNotifyHandler : AMRpcHandler { protected override async ETTask Run(Session session, C2G_BattleNotify request, G2C_BattleNotify response, Action reply) { WNPlayer player = session.GetComponent().GetMyPlayer(); if (player == null) { Log.Debug($"操作错误, player is null"); response.Error = ErrorCode.ERR_OperationError; reply(); return; } // 判断参数 if (string.IsNullOrEmpty(request.Message)) { Log.Debug($"参数错误, request.NameType={request.Message}"); response.Error = ErrorCode.ERR_ParameterError; reply(); return; } // 通知战斗服 Struct.TriggerEventNotify notifyMsg = new Struct.TriggerEventNotify(); notifyMsg.message = request.Message; player.GetXmdsManager().notifyBattleServer(player.Map.Id.ToString(), NotifyBSName.TriggerEvent, JsonSerializer.Serialize(notifyMsg)); reply(); await ETTask.CompletedTask; } } }