示例#1
0
        public ITransportDialer Dialer(Multiaddress laddr, TimeSpan?timeout = null, bool reusePort = true)
        {
            ITransportDialer d;

            if (_dialers.TryGetValue(laddr.ToString(), out d))
            {
                return(d);
            }

            d = CreateDialer(laddr, timeout, reusePort);
            _dialers.TryAdd(laddr.ToString(), d);
            return(d);
        }
示例#2
0
        public ITransportListener Listen(Multiaddress laddr)
        {
            if (!Matches(laddr))
            {
                throw new NotSupportedException($"Tcp transport cannot listen on {laddr}");
            }

            ITransportListener l;

            if (_listeners.TryGetValue(laddr.ToString(), out l))
            {
                return(l);
            }

            l = CreateListener(laddr);
            _listeners.TryAdd(laddr.ToString(), l);
            return(l);
        }
示例#3
0
        public void Add(Multiaddress address, Multiaddress observer)
        {
            Write(() =>
            {
                if (_addresses == null)
                {
                    _addresses = new Dictionary <string, ObservedAddress>();
                    _ttl       = AddressManager.OwnObservedAddrTTL;
                }

                var s = address.ToString();
                ObservedAddress oa;
                if (!_addresses.TryGetValue(s, out oa))
                {
                    oa = new ObservedAddress(address, new HashSet <string>());
                    _addresses.Add(s, oa);
                }

                oa.SeenBy.Add(ToObserverGroup(observer));
                oa.LastSeen = DateTime.Now;
            });
        }