//private readonly ILog _logger;
 public BsProtocolReceiveFilter(IAppSession appSession)
 {
     State                 = FilterState.Normal;
     _appSession           = (BsProtocolSession)appSession;
     _appSession.FragBytes = new List <byte>();
     //_logger = LogManager.GetLogger(GetType());
 }
Esempio n. 2
0
        //private static readonly ILog Logger = LogManager.GetLogger(typeof(BsPackage));

        public static void SeparatePacket(this IList <byte> source, BsProtocolSession session)
        {
            if (!source.Any())
            {
                return;
            }
            if (source.Count > 1 && source[0] == Mark && source[1] != Mark)
            {
                var packet = SeparateSinglePacket(source);
                if (packet.LastOrDefault() == Mark)
                {
                    PacketQueue.Enqueue(packet);
                    if (PacketQueue.Count > BorderCount)
                    {
                        AutoResetEvent.Set();
                    }
                    SeparatePacket(source.Skip(packet.Count).ToList(), session);
                }
                else
                {
                    session.FragBytes.AddRange(source);
                }
            }
            else
            {
                session.FragBytes.AddRange(source);
            }
        }