C# Класс Open.Nat.NatDiscoverer

Показать файл Открыть проект Примеры использования класса

Открытые свойства

Свойство Тип Описание
TraceSource System.Diagnostics.TraceSource

Открытые методы

Метод Описание
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.

Приватные методы

Метод Описание
DiscoverAsync ( PortMapper portMapper, bool onlyOne, CancellationTokenSource cts ) : Task>
ReleaseSessionMappings ( ) : void
RenewMappings ( object state ) : void

Описание методов

DiscoverDeviceAsync() публичный Метод

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
Результат Task

DiscoverDeviceAsync() публичный Метод

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
Результат Task

DiscoverDevicesAsync() публичный Метод

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
Результат Task>

ReleaseAll() публичный статический Метод

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
Результат void

Описание свойств

TraceSource публичное статическое свойство

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
Результат System.Diagnostics.TraceSource