Beispiel #1
0
        public void Create(Address?address, int peerLimit, int channelLimit, uint incomingBandwidth, uint outgoingBandwidth)
        {
            var version = LENet.Version.Patch420;

            if (_host != null)
            {
                throw new InvalidOperationException("Already created.");
            }

            if (peerLimit < 0 || peerLimit > version.MaxPeerID)
            {
                throw new ArgumentOutOfRangeException("peerLimit");
            }

            CheckChannelLimit(channelLimit);

            LENet.Address?nativeAddress = null;
            if (address is Address addr)
            {
                nativeAddress = new LENet.Address(addr.IPv4Host, addr.Port);
            }
            try
            {
                _host = new LENet.Host(version, nativeAddress, (uint)peerLimit, (uint)channelLimit, incomingBandwidth, outgoingBandwidth);
            }
            catch (Exception)
            {
                throw new ENetException(0, "Host creation call failed.");
            }
        }
Beispiel #2
0
 protected virtual void Dispose(bool disposing)
 {
     if (_host != null)
     {
         _host.Dispose();
         _host = null;
     }
 }