internal void OnHeartbeat() { try { interactive?.OnHeartbeat(false); subscription?.OnHeartbeat(false); } catch (Exception ex) { multiplexer.OnInternalError(ex, EndPoint); } }
#pragma warning disable 1998 // NET40 is sync, not async, currently internal async Task ResolveEndPointsAsync(ConnectionMultiplexer multiplexer, TextWriter log) { Dictionary <string, IPAddress> cache = new Dictionary <string, IPAddress>(StringComparer.InvariantCultureIgnoreCase); for (int i = 0; i < endpoints.Count; i++) { var dns = endpoints[i] as DnsEndPoint; if (dns != null) { try { IPAddress ip; if (dns.Host == ".") { endpoints[i] = new IPEndPoint(IPAddress.Loopback, dns.Port); } else if (cache.TryGetValue(dns.Host, out ip)) { // use cache endpoints[i] = new IPEndPoint(ip, dns.Port); } else { multiplexer.LogLocked(log, "Using DNS to resolve '{0}'...", dns.Host); #if NET40 var ips = Dns.GetHostAddresses(dns.Host); #else var ips = await Dns.GetHostAddressesAsync(dns.Host).ObserveErrors().ForAwait(); #endif if (ips.Length == 1) { ip = ips[0]; multiplexer.LogLocked(log, "'{0}' => {1}", dns.Host, ip); cache[dns.Host] = ip; endpoints[i] = new IPEndPoint(ip, dns.Port); } } } catch (Exception ex) { multiplexer.OnInternalError(ex); multiplexer.LogLocked(log, ex.Message); } } } }
internal void OnHeartbeat() { try { var tmp = interactive; if (tmp != null) { tmp.OnHeartbeat(false); } tmp = subscription; if (tmp != null) { tmp.OnHeartbeat(false); } } catch (Exception ex) { multiplexer.OnInternalError(ex, EndPoint); } }
internal void OnHeartbeat() { // don't overlap operations on an endpoint if (Interlocked.CompareExchange(ref _heartBeatActive, 1, 0) == 0) { try { interactive?.OnHeartbeat(false); subscription?.OnHeartbeat(false); } catch (Exception ex) { multiplexer.OnInternalError(ex, EndPoint); } finally { Interlocked.Exchange(ref _heartBeatActive, 0); } } }
internal async Task ResolveEndPointsAsync(ConnectionMultiplexer multiplexer, LogProxy log) { var cache = new Dictionary <string, IPAddress>(StringComparer.OrdinalIgnoreCase); for (int i = 0; i < EndPoints.Count; i++) { if (EndPoints[i] is DnsEndPoint dns) { try { if (dns.Host == ".") { EndPoints[i] = new IPEndPoint(IPAddress.Loopback, dns.Port); } else if (cache.TryGetValue(dns.Host, out IPAddress ip)) { // use cache EndPoints[i] = new IPEndPoint(ip, dns.Port); } else { log?.WriteLine($"Using DNS to resolve '{dns.Host}'..."); var ips = await Dns.GetHostAddressesAsync(dns.Host).ObserveErrors().ForAwait(); if (ips.Length == 1) { ip = ips[0]; log?.WriteLine($"'{dns.Host}' => {ip}"); cache[dns.Host] = ip; EndPoints[i] = new IPEndPoint(ip, dns.Port); } } } catch (Exception ex) { multiplexer.OnInternalError(ex); log?.WriteLine(ex.Message); } } } }
#pragma warning disable 1998 // NET40 is sync, not async, currently internal async Task ResolveEndPointsAsync(ConnectionMultiplexer multiplexer, TextWriter log) { Dictionary<string, IPAddress> cache = new Dictionary<string, IPAddress>(StringComparer.OrdinalIgnoreCase); for (int i = 0; i < endpoints.Count; i++) { var dns = endpoints[i] as DnsEndPoint; if (dns != null) { try { IPAddress ip; if (dns.Host == ".") { endpoints[i] = new IPEndPoint(IPAddress.Loopback, dns.Port); } else if (cache.TryGetValue(dns.Host, out ip)) { // use cache endpoints[i] = new IPEndPoint(ip, dns.Port); } else { multiplexer.LogLocked(log, "Using DNS to resolve '{0}'...", dns.Host); #if NET40 var ips = Dns.GetHostAddresses(dns.Host); #else var ips = await Dns.GetHostAddressesAsync(dns.Host).ObserveErrors().ForAwait(); #endif if (ips.Length == 1) { ip = ips[0]; multiplexer.LogLocked(log, "'{0}' => {1}", dns.Host, ip); cache[dns.Host] = ip; endpoints[i] = new IPEndPoint(ip, dns.Port); } } } catch (Exception ex) { multiplexer.OnInternalError(ex); multiplexer.LogLocked(log, ex.Message); } } } }
private void OnInternalError(Exception exception, [CallerMemberName] string origin = null) { multiplexer.OnInternalError(exception, serverEndPoint.EndPoint, connectionType, origin); }