private void Check(byte[] data) { int index = 0; var conv = ConverHelper.GetU32(data, index); Tuple <Queue <KCPPackage>, KCP> item = null; lock (SessionDic) { if (!SessionDic.TryGetValue(conv, out item)) { item = new Tuple <Queue <KCPPackage>, KCP>(new Queue <KCPPackage>(), new KCP(conv)); //如果会话中不存在conv则认为这是新连接,创建KCP状态机 SessionDic.Add(conv, item); new Thread(Update) { IsBackground = true }.Start(item); } } while (index < data.Length) { var tempItem = KCPPackage.Parse(data, index); if (tempItem.Item2 == 0) { break; } index += tempItem.Item2; item.Item1.Enqueue(tempItem.Item1); } }