123456789101112131415161718192021222324252627282930313233343536373839 |
- 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);
- }
- }
- }
- }
- }
- }
|