Exemple #1
0
        public bool Send(byte channelID, ENetPacket packet)
        {
            if (State != ENetPeerState.Connected || channelID > Channels.Count)
            {
                return(false);
            }
            if (packet.Data.Length > FragmentLength) //Packet bigger than MTU, fragment it
            {
                ushort sequenceNo = Util.ToNetOrder((ushort)(OutgoingReliableSequenceNumber + 1));
                uint   fragCount  = Util.ToNetOrder((uint)((packet.Data.Length + FragmentLength - 1) / FragmentLength));

                for (int fragmentNo = 0, fragmentOffset = 0; fragmentOffset < packet.Data.Length; fragmentNo++, fragmentOffset += FragmentLength)
                {
                    if (packet.Data.Length - fragmentOffset < FragmentLength)
                    {
                        FragmentLength = packet.Data.Length - fragmentOffset;
                    }
                }
            }
        }
Exemple #2
0
        public bool Send(byte channelID, ENetPacket packet)
        {
            if(State != ENetPeerState.Connected || channelID > Channels.Count) return false;
            if(packet.Data.Length > FragmentLength){ //Packet bigger than MTU, fragment it
                ushort sequenceNo = Util.ToNetOrder((ushort)(OutgoingReliableSequenceNumber + 1));
                uint fragCount = Util.ToNetOrder((uint)((packet.Data.Length + FragmentLength - 1) / FragmentLength));

                for(int fragmentNo = 0, fragmentOffset = 0; fragmentOffset < packet.Data.Length; fragmentNo++, fragmentOffset += FragmentLength){
                    if (packet.Data.Length - fragmentOffset < FragmentLength) FragmentLength = packet.Data.Length - fragmentOffset;
                }
            }
        }