public void Create(Address?address, int peerLimit, int channelLimit, uint incomingBandwidth, uint outgoingBandwidth) { if (_host != null) { throw new InvalidOperationException("Already created."); } if (peerLimit < 0 || peerLimit > Native.ENET_PROTOCOL_MAXIMUM_PEER_ID) { throw new ArgumentOutOfRangeException("peerLimit"); } CheckChannelLimit(channelLimit); if (address != null) { var nativeAddress = address.Value.NativeData; _host = Native.enet_host_create(ref nativeAddress, (IntPtr)peerLimit, incomingBandwidth, outgoingBandwidth); } else { _host = Native.enet_host_create(null, (IntPtr)peerLimit, incomingBandwidth, outgoingBandwidth); } if (_host == null) { throw new ENetException(0, "Host creation call failed."); } }
protected virtual void Dispose(bool disposing) { if (_host != null) { Native.enet_host_destroy(_host); _host = null; } }
public void Create(Address? address, int peerLimit, int channelLimit, uint incomingBandwidth, uint outgoingBandwidth) { if (_host != null) { throw new InvalidOperationException("Already created."); } if (peerLimit < 0 || peerLimit > Native.ENET_PROTOCOL_MAXIMUM_PEER_ID) { throw new ArgumentOutOfRangeException("peerLimit"); } CheckChannelLimit(channelLimit); if (address != null) { var nativeAddress = address.Value.NativeData; _host = Native.enet_host_create(ref nativeAddress, (IntPtr) peerLimit, (IntPtr) channelLimit, incomingBandwidth, outgoingBandwidth); } else { _host = Native.enet_host_create(null, (IntPtr) peerLimit, (IntPtr) channelLimit, incomingBandwidth, outgoingBandwidth); } if (_host == null) { throw new ENetException(0, "Host creation call failed."); } }