public string StartTopicImport(string uid, MqttImportTopicParameters parameters) { if (parameters == null) { throw new ArgumentNullException(nameof(parameters)); } if (string.IsNullOrEmpty(uid)) { uid = Guid.NewGuid().ToString("D"); } var importer = new MqttTopicImporter(parameters, this, _logger); importer.Start(); lock (Importers) { if (Importers.TryGetValue(uid, out var existingImporter)) { existingImporter.Stop(); } Importers[uid] = importer; } _logger.Log(LogLevel.Information, "Started importer '{0}' for topic '{1}' from server '{2}'.", uid, parameters.Topic, parameters.Server); return(uid); }
public void StopTopicImport(string uid) { if (uid == null) { throw new ArgumentNullException(nameof(uid)); } lock (Importers) { if (Importers.TryGetValue(uid, out var importer)) { importer.Stop(); _logger.Log(LogLevel.Information, "Stopped importer '{0}'."); } Importers.Remove(uid); } }