public TNLConnection() { _key = 0U; _oneTimeKey = 0U; _playerCOID = 0L; _fragmentCounter = 1; SetFixedRateParameters(50, 50, 40000, 40000); SetPingTimeouts(7000, 6); _fragmentGuaranteed = new SFragmentData(); _fragmentNonGuaranteed = new SFragmentData(); _fragmentGuaranteedOrdered = new SFragmentData(); }
// ReSharper disable UnusedParameter.Local private void ProcessFragment(ByteBuffer theData, SFragmentData sFragment, UInt32 type, UInt16 fragment, UInt16 fragmentId, UInt16 fragmentCount) // ReSharper restore UnusedParameter.Local { if (sFragment.FragmentId != fragment) { if (fragment > 0) Console.WriteLine("Dropped fragment: {0} vs {1}", sFragment.FragmentId, fragment); sFragment.FragmentId = fragment; sFragment.TotalSize = 0; sFragment.MapFragments.Clear(); } sFragment.MapFragments.Add(fragmentId, theData); sFragment.TotalSize += theData.GetBufferSize(); if (sFragment.MapFragments.Count == fragmentCount) { Console.WriteLine("Reassembling fragment {0} ({1} fragments", sFragment.FragmentId, fragmentCount); var combined = new ByteBuffer(sFragment.TotalSize); var off = 0U; for (var i = 0; i < sFragment.MapFragments.Count; ++i) { if (!sFragment.MapFragments.ContainsKey(i)) { Console.WriteLine("Big error! Fragment doesn't contain a buffer! Fragment: {0} | Index: {1}", fragment, i); return; } var buff = sFragment.MapFragments[i]; Array.Copy(buff.GetBuffer(), 0, combined.GetBuffer(), off, buff.GetBufferSize()); off += buff.GetBufferSize(); } sFragment.FragmentId = 0; sFragment.TotalSize = 0; sFragment.MapFragments.Clear(); HandlePacket(combined); } }