Пример #1
0
        /// <summary>
        /// Stops the discovery service.
        /// </summary>
        public async Task StopAsync()
        {
            if (IsStarted)
            {
                Logger.LogInformation("Stopping...");

                await _tcpValidationServer.StopAsync();

                //Transmit the discovery packet one more time so clients can tell that we have disconnected.
                BroadcastDiscoveryPacket();

                _timer.Stop();
                IsStarted = false;
                Logger.LogInformation("Stopped.");
            }
        }
Пример #2
0
        /// <summary>
        /// Stops the service.
        /// </summary>
        private async void Stop()
        {
            if (IsStarted)
            {
                //Stop the tcp server.
                await _server.StopAsync();

                //Stop the discovery service.
                await _discoveryService.StopAsync();

                IsStarted = false;

                //Disconnect all clients.
                _clients.ToList().ForEach(async x => await x.DisconnectAsync());
                _clients.Clear();
            }
        }