コード例 #1
0
ファイル: ENetHost.cs プロジェクト: wyb314/ENetSharp
 public ENetHost(IPEndPoint listenAddress, ushort peerCount, ENetChannelTypeLayout channelLayout)
 {
     if (peerCount > PROTOCOL_MAXIMUM_PEER_ID) throw new ArgumentException("The given peer count exceeds the protocol maximum of " + PROTOCOL_MAXIMUM_PEER_ID);
     PeerCount = peerCount;
     ChannelLayout = channelLayout;
     connection = new UdpClient(listenAddress);
     for (ushort i = 1; i <= peerCount; i++)
     {
         AvailablePeerIds.Enqueue(i);
     }
 }
コード例 #2
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]);
     }
 }