public List <Packet> PrepareSend(List <Packet> packetsToSend)
        {
            var sendList    = new List <Packet>();
            var sendInBatch = new List <Packet>();

            foreach (Packet packet in packetsToSend)
            {
                // We must send forced clear messages in single message batch because
                // we can't mix them with un-encrypted messages for obvious reasons.
                // If need be, we could put these in a batch of it's own, but too rare
                // to bother.
                if (packet.ForceClear)
                {
                    var wrapper = McpeWrapper.CreateObject();
                    wrapper.ReliabilityHeader.Reliability = Reliability.ReliableOrdered;
                    wrapper.ForceClear = true;
                    wrapper.payload    = Compression.CompressPacketsForWrapper(new List <Packet> {
                        packet
                    });
                    wrapper.Encode();                     // prepare
                    packet.PutPool();
                    sendList.Add(wrapper);
                    continue;
                }

                if (packet is McpeWrapper)
                {
                    packet.ReliabilityHeader.Reliability = Reliability.ReliableOrdered;
                    sendList.Add(packet);
                    continue;
                }

                if (!packet.IsMcpe)
                {
                    packet.ReliabilityHeader.Reliability = packet.ReliabilityHeader.Reliability != Reliability.Undefined ? packet.ReliabilityHeader.Reliability : Reliability.Reliable;
                    sendList.Add(packet);
                    continue;
                }

                packet.ReliabilityHeader.Reliability = Reliability.ReliableOrdered;

                sendInBatch.Add(OnSendCustomPacket(packet));
            }

            if (sendInBatch.Count > 0)
            {
                var batch = McpeWrapper.CreateObject();
                batch.ReliabilityHeader.Reliability = Reliability.ReliableOrdered;
                batch.payload = Compression.CompressPacketsForWrapper(sendInBatch);
                batch.Encode();                 // prepare
                sendList.Add(batch);
            }

            return(sendList);
        }