Example #1
0
 internal ENetPeer(IPEndPoint Address, ushort IncomingPeerID, ENetProtocolConnect packet, ENetChannelTypeLayout channelLayout)
 {
     this.Address = Address;
     this.SessionID = packet.SessionID;
     this.MTU = packet.MTU < PROTOCOL_MINIMUM_MTU ? PROTOCOL_MINIMUM_MTU : packet.MTU > PROTOCOL_MAXIMUM_MTU ? PROTOCOL_MAXIMUM_MTU : packet.MTU;
     this.FragmentLength = (MTU - ENetCommand.SEND_FRAGMENT.Size()) - sizeof(ENetProtocolHeader);
     this.OutgoingPeerID = packet.OutgoingPeerID;
     this.IncomingPeerID = IncomingPeerID;
     this.WindowSize = PROTOCOL_MAXIMUM_WINDOW_SIZE > packet.WindowSize ? packet.WindowSize : PROTOCOL_MAXIMUM_WINDOW_SIZE;
     this.Channels = new ConcurrentDictionary<byte, ENetChannel>();
     for(byte i = 0; i < channelLayout.ChannelCount(); i++){
         Channels[i] = new ENetChannel(channelLayout[i]);
     }
 }
Example #2
0
 bool DropSequencedData(ENetChannel channel, ENetProtocolCommandHeader header)
 {
     ushort reliableWindow = (ushort)(header.ReliableSequenceNumber / PEER_RELIABLE_WINDOW_SIZE);
     ushort currentWindow = (ushort)(channel.IncomingSequenceNumber / PEER_RELIABLE_WINDOW_SIZE);
     if (header.ReliableSequenceNumber < channel.IncomingSequenceNumber) reliableWindow += PEER_RELIABLE_WINDOWS;
     return reliableWindow < currentWindow || reliableWindow >= currentWindow + PEER_FREE_RELIABLE_WINDOWS - 1;
 }