public UdpProxy( IReadOnlyTcpStream clientStream, IUdpClientFactory clientFactory, IDatagramInterceptor interceptor, ArrayPool <byte> bufferPool, ITimerFactory timerFactory, ILoggerFactory loggerFactory) { if (clientFactory == null) { throw new ArgumentNullException(nameof(clientFactory)); } if (loggerFactory == null) { throw new ArgumentNullException(nameof(loggerFactory)); } this._clientStream = clientStream ?? throw new ArgumentNullException(nameof(clientStream)); this._interceptor = interceptor ?? throw new ArgumentNullException(nameof(interceptor)); this._bufferPool = bufferPool ?? throw new ArgumentNullException(nameof(bufferPool)); this._boundClient = clientFactory.CreateBoundUdpClient( new IPEndPoint(((IPEndPoint)clientStream.LocalEndPoint).Address, 0)); this._relayClient = clientFactory.CreateUdpClient(); this._reassembler = new DatagramReassembler(timerFactory, this._bufferPool); this._clientEndPointTask = new TaskCompletionSource <EndPoint>(TaskCreationOptions.RunContinuationsAsynchronously); this._clientSessionTerminationSource = new CancellationTokenSource(); this._log = loggerFactory.CreateLogger(this.GetType().Name); this._log.LogInformation("Started UDP listener on {0}", this.BindEndPoint); }
public FakeUdpClientFactory(IBoundUdpClient stagedBoundClient, IUdpClient stagedClient) { this._stagedBoundUdpClient = stagedBoundClient ?? throw new ArgumentNullException(nameof(stagedBoundClient)); this._stagedUdpClient = stagedClient ?? throw new ArgumentNullException(nameof(stagedClient)); }