/// <summary> /// Gets the Mikrotik connection. /// </summary> /// <returns></returns> private ITikConnection GetConnection() { PackageHost.WriteInfo("Connecting to {0} ...", PackageHost.GetSettingValue("Host")); ITikConnection connection = ConnectionFactory.CreateConnection(TikConnectionType.Api); try { connection.Open(PackageHost.GetSettingValue("Host"), PackageHost.GetSettingValue("Username"), PackageHost.GetSettingValue("Password")); PackageHost.WriteInfo("Connected!"); } catch (Exception ex) { PackageHost.WriteError($"Unable to connect to {PackageHost.GetSettingValue("Host")} : {ex.Message}"); connection.Dispose(); connection = null; } return(connection); }
public void Cleanup() { _connection.Dispose(); }
public void Dispose() { _connection.Close(); _connection.Dispose(); }