private void CloseDataChannel() { try { _log.Information("Relay: {relay}. Closing the data channel", _relay); _uplinkPumps.DisposeAndClear(); _downlinkPump.IgnoreException(x => x.Dispose()); _downlinkPump = null; if (_dataChannel != null) { _dataChannel.Dispose(); _dataChannel = null; } _canAcceptUntil = DateTime.MaxValue; OnDataChannelClosed?.Invoke(this); _log.Debug("Relay: {relay}. The data channel was closed", _relay); } catch { // intentional } }
private void EnsureDownlinkPump(HybridConnectionStream stream) { _dataChannel = new RemoteRelayDataChannel(_log, _metrics.Remote, stream); _downlinkPump = new DownlinkPump(_log, _dataChannel); _metrics.RemoteEstablishedTunnels.Increment(); _log.Verbose("Downlink pump is created and starting"); _downlinkPump.RunAsync().ContinueWith(OnDownlinkPumpCompleted); }
public RelayTunnel(ILogger logger, TunnelMetrics metrics, HybridConnectionStream relayStream, ILocalDataChannelFactory localFactory, TunnelCompleted tunnelCompleted) { _log = logger.ForContext(GetType()); _uplinkPumps = new ConcurrentDictionary <object, UplinkPump>(); _localDataChannelFactory = localFactory; _tunnelCompleted = tunnelCompleted; _metrics = metrics; _relayDataChannel = new RemoteRelayDataChannel(logger, metrics.Remote, relayStream); _downlinkPump = new DownlinkPump(logger, _relayDataChannel, CreateLocalDataChannel); }