using System; namespace XGame.Framework.Network { internal class MsgProcesser : IMsgProcesser { private ISessionContext _context; private IMsgReceiverListener _listener; public MsgProcesser(ISessionContext context, IMsgReceiverListener listener) { _context = context; _listener = listener; } public void Process(IMessage message) { if (message != null) { _listener.OnPreMessage(message); IMsgController msgController = _context.Generator.GetController(message.ProtocolID); if (null != msgController) { try { msgController.Process(message, _listener); _context.Generator.RecycleMessage(message); } catch (Exception e) { Log.Exception($"[Net] {msgController.GetType().FullName}.Process protoId: {message.ProtocolID}, Error: \n", e); _context.Generator.RecycleMessage(message); } } } } } }