Example #1
0
            // 处理接受数据
            public void DataReceive(object sender, DataEventArgs dataEvent)
            {
                // 将数据分段,保存到阻塞队列中
                byte[] data = dataEvent.Data;

                stream.insert(stream.size(), data, dataEvent.Offset, dataEvent.Length);
                // 分割
                IList <ArraySegment <byte> > result = stream.getByteArrayByMark(Mark);

                foreach (ArraySegment <byte> arr in result)
                {
                    conn.m_ReceQueue.Enqueue(arr);
                }

                handler.OnData(conn);
                GC.Collect();
            }