C# Class Open.Nat.NatDiscoverer

Mostrar archivo Open project: mcatanzariti/Open.NAT Class Usage Examples

Public Properties

Property Type Description
TraceSource System.Diagnostics.TraceSource

Public Methods

Method Description
DiscoverDeviceAsync ( ) : Task

Discovers and returns an UPnp or Pmp NAT device; otherwise a NatDeviceNotFoundException exception is thrown after 3 seconds.

DiscoverDeviceAsync ( PortMapper portMapper, CancellationTokenSource cancellationTokenSource ) : Task

Discovers and returns a NAT device for the specified type; otherwise a NatDeviceNotFoundException exception is thrown when it is cancelled.

It allows to specify the NAT type to discover as well as the cancellation token in order.

DiscoverDevicesAsync ( PortMapper portMapper, CancellationTokenSource cancellationTokenSource ) : Task>

Discovers and returns all NAT devices for the specified type. If no NAT device is found it returns an empty enumerable

ReleaseAll ( ) : void

Release all ports opened by Open.NAT.

If ReleaseOnShutdown value is true, it release all the mappings created through the library.

Private Methods

Method Description
DiscoverAsync ( PortMapper portMapper, bool onlyOne, CancellationTokenSource cts ) : Task>
ReleaseSessionMappings ( ) : void
RenewMappings ( object state ) : void

Method Details

DiscoverDeviceAsync() public method

Discovers and returns an UPnp or Pmp NAT device; otherwise a NatDeviceNotFoundException exception is thrown after 3 seconds.
when no NAT found before 3 seconds.
public DiscoverDeviceAsync ( ) : Task
return Task

DiscoverDeviceAsync() public method

Discovers and returns a NAT device for the specified type; otherwise a NatDeviceNotFoundException exception is thrown when it is cancelled.
It allows to specify the NAT type to discover as well as the cancellation token in order.
when no NAT found before cancellation
public DiscoverDeviceAsync ( PortMapper portMapper, CancellationTokenSource cancellationTokenSource ) : Task
portMapper PortMapper Port mapper protocol; Upnp, Pmp or both
cancellationTokenSource System.Threading.CancellationTokenSource Cancellation token source for cancelling the discovery process
return Task

DiscoverDevicesAsync() public method

Discovers and returns all NAT devices for the specified type. If no NAT device is found it returns an empty enumerable
public DiscoverDevicesAsync ( PortMapper portMapper, CancellationTokenSource cancellationTokenSource ) : Task>
portMapper PortMapper Port mapper protocol; Upnp, Pmp or both
cancellationTokenSource System.Threading.CancellationTokenSource Cancellation token source for cancelling the discovery process
return Task>

ReleaseAll() public static method

Release all ports opened by Open.NAT.
If ReleaseOnShutdown value is true, it release all the mappings created through the library.
public static ReleaseAll ( ) : void
return void

Property Details

TraceSource public_oe static_oe property

The TraceSource instance used for debugging and Troubleshooting
At least one trace listener has to be added to the Listeners collection if a trace is required; if no listener is added there will no be tracing to analyse. Open.NAT only supports SourceLevels.Verbose, SourceLevels.Error, SourceLevels.Warning and SourceLevels.Information.
public static TraceSource,System.Diagnostics TraceSource
return System.Diagnostics.TraceSource