Пример #1
0
        public LocalNodeRecords(ILoggerFactory logfac)
        {
            LocalNodes = new List <LocalNodeInfo>();
            sharedPCs  = new List <NodeShareInfo>();

            BindPort           = Definition.MulticastPort;
            TargetPort         = new[] { Definition.MulticastPort };
            loggerFactory      = logfac;
            logger             = loggerFactory.CreateLogger <LocalNodeRecords>();
            _BroadcastingTimer = new System.Threading.Timer(OnBroadcastingTimer, null, Timeout.Infinite, Timeout.Infinite);
            durationCount      = 0;

            _Network = new LocalNodesNetwork(loggerFactory);
            _Network.OnReceiveNodeInfo = OnReceiveNodeInfo;
            _Network.OnError           = OnNetlayerError;

            State = NodeDiscoveryState.Created;

            SetupNodeInfoQueue();
        }
Пример #2
0
        protected virtual void Dispose(bool disposing)
        {
            if (!disposedValue)
            {
                logger.LogInformation("Take down LocalNodeRecords");
                disposedValue = true;
                if (disposing)
                {
                    _Network?.Dispose();
                    _Network = null;

                    _BroadcastingTimer.Change(Timeout.Infinite, Timeout.Infinite);
                    _BroadcastingTimer?.Dispose();
                    _BroadcastingTimer = null;
                    ReceivedNodeInfosSubject?.Dispose();
                    ReceivedNodeInfosSubject = null;
                    rxduration?.Dispose();
                    rxduration = null;
                    Httpclient?.Dispose();
                    Httpclient = null;
                }
            }
        }