Ejemplo n.º 1
0
        /// <summary>
        /// Starts the discovery service.
        /// </summary>
        public async Task StartAsync()
        {
            if (!IsStarted)
            {
                Logger.LogInformation("Starting...");
                Logger.LogDebug("Discovery Info: {@DiscoveryInfo}", DiscoveryInfo);

                _tcpValidationServer = new ResonanceTcpServer(Port);
                _tcpValidationServer.ConnectionRequest += (x, e) =>
                {
                    e.Decline();
                };

                await _tcpValidationServer.StartAsync();

                _timer          = new Timer();
                _timer.Interval = Interval.TotalMilliseconds;
                _timer.Elapsed += (_, __) => BroadcastDiscoveryPacket();
                _timer.Enabled  = true;
                _timer.Start();

                IsStarted = true;
                Logger.LogInformation("Started.");
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Starts the service.
        /// </summary>
        private async void Start()
        {
            if (!IsStarted)
            {
                //Start the TCP server.
                IsStarted = true;
                _server   = new ResonanceTcpServer(Port);
                _server.ConnectionRequest += OnConnectionRequest;
                await _server.StartAsync();

                //Start the discovery service.
                _discoveryService.DiscoveryInfo = new DiscoveryInfo()
                {
                    ServiceName = ServiceName, Port = Port
                };
                await _discoveryService.StartAsync();
            }
        }