Exemplo n.º 1
0
        public void Start(int webport, string thisnodeid)
        {
            try
            {
                if (State == NodeDiscoveryState.Listening)
                {
                    _Network.EnsureListenSocketFine();
                    return;
                }

                WebServerPort = webport;
                ThisNodeID    = thisnodeid;

                _Network.Start(BindPort, TargetPort, WebServerPort, ThisNodeID);
                _Network.SendSearch(TargetPort);
                _Network.SendAnnounce(true);
                RefreshSelfNode();
                _BroadcastingTimer.Change(RepublicTime, RepublicTime);

                _Network.SendSearch(TargetPort);

                State = NodeDiscoveryState.Listening;
            }
            catch (Exception e)
            {
                logger.LogError(e, "Exception in LocalNodeRecords:Start");
                throw;
            }
        }
Exemplo n.º 2
0
        public NodeDiscovery(ILoggerFactory logfac)
        {
            BindPort      = Definition.MulticastPort;
            TargetPort    = new[] { Definition.MulticastPort };
            loggerFactory = logfac;
            logger        = loggerFactory.CreateLogger("NodeDiscovery");

            timer              = new System.Threading.Timer(OnTimer, null, Timeout.Infinite, Timeout.Infinite);
            _SocketProxies     = new Dictionary <IPAddress, SsdpServerProxy>();
            udpMulticastServer = new UdpMulticastServer(loggerFactory.CreateLogger("UdpMulticastServer"));


            State     = NodeDiscoveryState.Created;
            TimeStamp = DateTime.UtcNow.ToFileTime();
        }
Exemplo n.º 3
0
        //not thread safe
        public void StartMonitoring()
        {
            if (State == NodeDiscoveryState.Listening)
            {
                return;
            }
            CleaEndPoints();
            var ips = GetLocalIPAddress();

            FillProxies(ips);

            lock (_SocketProxies)
            {
                foreach (var item in _SocketProxies)
                {
                    item.Value.Search();
                }
            }
            State = NodeDiscoveryState.Listening;
        }
Exemplo n.º 4
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();
        }