Esempio n. 1
0
        // Token: 0x06000706 RID: 1798 RVA: 0x0001B5A8 File Offset: 0x000197A8
        public virtual ProcessResult Process(ArraySegment <byte> segment)
        {
            BufferList bufferList = this.m_ReceiveCache;

            bufferList.Add(segment);
            int num = 0;
            IReceiveFilter <TPackageInfo> receiveFilter  = this.m_ReceiveFilter;
            SingleItemList <IPackageInfo> singleItemList = null;
            List <IPackageInfo>           list           = null;
            int total;

            for (;;)
            {
                int          count        = bufferList.Last.Count;
                TPackageInfo tpackageInfo = receiveFilter.Filter(bufferList, out num);
                if (receiveFilter.State == FilterState.Error)
                {
                    break;
                }
                if (this.m_MaxPackageLength > 0)
                {
                    total = bufferList.Total;
                    if (total > this.m_MaxPackageLength)
                    {
                        goto Block_3;
                    }
                }
                IReceiveFilter <TPackageInfo> nextReceiveFilter = receiveFilter.NextReceiveFilter;
                if (tpackageInfo != null)
                {
                    receiveFilter.Reset();
                }
                if (nextReceiveFilter != null)
                {
                    receiveFilter        = nextReceiveFilter;
                    this.m_ReceiveFilter = receiveFilter;
                }
                if (tpackageInfo == null)
                {
                    if (num <= 0)
                    {
                        goto IL_D4;
                    }
                    ArraySegment <byte> last = bufferList.Last;
                    if (num != count)
                    {
                        this.PushResetData(segment, num);
                    }
                }
                else
                {
                    if (list != null)
                    {
                        list.Add(tpackageInfo);
                    }
                    else if (singleItemList == null)
                    {
                        singleItemList = new SingleItemList <IPackageInfo>(tpackageInfo);
                    }
                    else
                    {
                        if (list == null)
                        {
                            list = new List <IPackageInfo>();
                        }
                        list.Add(singleItemList[0]);
                        list.Add(tpackageInfo);
                        singleItemList = null;
                    }
                    if (tpackageInfo is IBufferedPackageInfo && (tpackageInfo as IBufferedPackageInfo).Data is BufferList)
                    {
                        bufferList = (this.m_ReceiveCache = new BufferList());
                        if (num <= 0)
                        {
                            goto Block_14;
                        }
                    }
                    else
                    {
                        this.m_ReceiveCache.Clear();
                        if (num <= 0)
                        {
                            goto Block_15;
                        }
                    }
                    this.PushResetData(segment, num);
                }
            }
            return(ProcessResult.Create(ProcessState.Error));

Block_3:
            return(ProcessResult.Create(ProcessState.Error, string.Format("Max package length: {0}, current processed length: {1}", this.m_MaxPackageLength, total)));

IL_D4:
            return(ProcessResult.Create(ProcessState.Cached, this.GetNotNullOne(list, singleItemList)));

Block_14:
            return(ProcessResult.Create(ProcessState.Cached, this.GetNotNullOne(list, singleItemList)));

Block_15:
            return(ProcessResult.Create(ProcessState.Completed, this.GetNotNullOne(list, singleItemList)));
        }
Esempio n. 2
0
 // Token: 0x0600075B RID: 1883 RVA: 0x00006338 File Offset: 0x00004538
 public static ProcessResult Create(ProcessState state, string message)
 {
     return(ProcessResult.Create(state, message, null));
 }
Esempio n. 3
0
 // Token: 0x0600075C RID: 1884 RVA: 0x00006342 File Offset: 0x00004542
 public static ProcessResult Create(ProcessState state, IList <IPackageInfo> packages)
 {
     return(ProcessResult.Create(state, string.Empty, packages));
 }
Esempio n. 4
0
        public virtual ProcessResult Process(ArraySegment <byte> segment)
        {
            BufferList bufferList = m_ReceiveCache;

            bufferList.Add(segment);
            int rest = 0;
            IReceiveFilter <TPackageInfo> receiveFilter  = m_ReceiveFilter;
            SingleItemList <IPackageInfo> singleItemList = null;
            List <IPackageInfo>           list           = null;

            while (true)
            {
                int          count = bufferList.Last.Count;
                TPackageInfo val   = receiveFilter.Filter(bufferList, out rest);
                if (receiveFilter.State == FilterState.Error)
                {
                    return(ProcessResult.Create(ProcessState.Error));
                }
                if (m_MaxPackageLength > 0)
                {
                    int total = bufferList.Total;
                    if (total > m_MaxPackageLength)
                    {
                        return(ProcessResult.Create(ProcessState.Error, $"Max package length: {m_MaxPackageLength}, current processed length: {total}"));
                    }
                }
                IReceiveFilter <TPackageInfo> nextReceiveFilter = receiveFilter.NextReceiveFilter;
                if (val != null)
                {
                    receiveFilter.Reset();
                }
                if (nextReceiveFilter != null)
                {
                    receiveFilter = (m_ReceiveFilter = nextReceiveFilter);
                }
                if (val == null)
                {
                    if (rest > 0)
                    {
                        ArraySegment <byte> last = bufferList.Last;
                        if (rest != count)
                        {
                            PushResetData(segment, rest);
                        }
                        continue;
                    }
                    return(ProcessResult.Create(ProcessState.Cached, GetNotNullOne(list, singleItemList)));
                }
                if (list != null)
                {
                    list.Add(val);
                }
                else if (singleItemList == null)
                {
                    singleItemList = new SingleItemList <IPackageInfo>(val);
                }
                else
                {
                    if (list == null)
                    {
                        list = new List <IPackageInfo>();
                    }
                    list.Add(singleItemList[0]);
                    list.Add(val);
                    singleItemList = null;
                }
                if (val is IBufferedPackageInfo && (val as IBufferedPackageInfo).Data is BufferList)
                {
                    bufferList = (m_ReceiveCache = new BufferList());
                    if (rest <= 0)
                    {
                        return(ProcessResult.Create(ProcessState.Cached, GetNotNullOne(list, singleItemList)));
                    }
                }
                else
                {
                    m_ReceiveCache.Clear();
                    if (rest <= 0)
                    {
                        break;
                    }
                }
                PushResetData(segment, rest);
            }
            return(ProcessResult.Create(ProcessState.Completed, GetNotNullOne(list, singleItemList)));
        }