//============================================================ // <T>执行处理。</T> //============================================================ public void ProcessMessages() { // 读取所有网络数据 lock (_socketData) { _data.Append(_socketData); _socketData.Clear(); } // 处理消息 if (_data.Length > 0) { while (true) { // 检查最小长度 if (_data.Remain <= RInt.BYTE_SIZE) { break; } // 测试数据是否完整 int peekLength = _data.PeekInt32(); if (_data.Remain >= peekLength) { ProcessMessage(); } } int position = _data.Position; if (position > 0) { _data.Erase(0, position); _data.Position = 0; } } }