From 3adadb1c6355754c6928c63c43ac0e919253ef86 Mon Sep 17 00:00:00 2001 From: Deantwo <2676134+Deantwo@users.noreply.github.com> Date: Tue, 21 Jan 2020 12:33:47 +0100 Subject: [PATCH] Added new AsteriskVersions to determineVersion() Added up to Asterisk v17. Added an attempt at getting newer versions too. --- .../Asterisk.NET/Manager/ManagerConnection.cs | 104 +++++++++++------- 1 file changed, 66 insertions(+), 38 deletions(-) diff --git a/Asterisk.2013/Asterisk.NET/Manager/ManagerConnection.cs b/Asterisk.2013/Asterisk.NET/Manager/ManagerConnection.cs index daf82bb..e94bd2c 100644 --- a/Asterisk.2013/Asterisk.NET/Manager/ManagerConnection.cs +++ b/Asterisk.2013/Asterisk.NET/Manager/ManagerConnection.cs @@ -167,7 +167,7 @@ namespace AsterNET.Manager /// Default Slow Reconnect interval in milliseconds. private int reconnectIntervalMax = 10000; - public char[] VAR_DELIMITER = { '|' }; + public char[] VAR_DELIMITER = { '|' }; #endregion @@ -1646,43 +1646,68 @@ namespace AsterNET.Manager if (m.Groups.Count >= 2) { version = m.Groups[1].Value; - if (version.StartsWith("1.4.")) - { - VAR_DELIMITER = new char[] { '|' }; - return AsteriskVersion.ASTERISK_1_4; - } - else if (version.StartsWith("1.6.")) - { - VAR_DELIMITER = new char[] { '|' }; - return Manager.AsteriskVersion.ASTERISK_1_6; - } - else if (version.StartsWith("1.8.")) - { - VAR_DELIMITER = new char[] { '|' }; - return Manager.AsteriskVersion.ASTERISK_1_8; - } - else if (version.StartsWith("10.")) - { - VAR_DELIMITER = new char[] { '|' }; - return Manager.AsteriskVersion.ASTERISK_10; - } - else if (version.StartsWith("11.")) - { - VAR_DELIMITER = new char[] { ',' }; - return Manager.AsteriskVersion.ASTERISK_11; - } - else if (version.StartsWith("12.")) - { - VAR_DELIMITER = new char[] { ',' }; - return Manager.AsteriskVersion.ASTERISK_12; - } - else if (version.StartsWith("13.")) - { - VAR_DELIMITER = new char[] { ',' }; - return Manager.AsteriskVersion.ASTERISK_13; - } - else - throw new ManagerException("Unknown Asterisk version " + version); + if (version.StartsWith("1.4.")) + { + VAR_DELIMITER = new char[] { '|' }; + return AsteriskVersion.ASTERISK_1_4; + } + else if (version.StartsWith("1.6.")) + { + VAR_DELIMITER = new char[] { '|' }; + return Manager.AsteriskVersion.ASTERISK_1_6; + } + else if (version.StartsWith("1.8.")) + { + VAR_DELIMITER = new char[] { '|' }; + return Manager.AsteriskVersion.ASTERISK_1_8; + } + else if (version.StartsWith("10.")) + { + VAR_DELIMITER = new char[] { '|' }; + return Manager.AsteriskVersion.ASTERISK_10; + } + else if (version.StartsWith("11.")) + { + VAR_DELIMITER = new char[] { ',' }; + return Manager.AsteriskVersion.ASTERISK_11; + } + else if (version.StartsWith("12.")) + { + VAR_DELIMITER = new char[] { ',' }; + return Manager.AsteriskVersion.ASTERISK_12; + } + else if (version.StartsWith("13.")) + { + VAR_DELIMITER = new char[] { ',' }; + return Manager.AsteriskVersion.ASTERISK_13; + } + else if (version.StartsWith("14.")) + { + VAR_DELIMITER = new char[] { ',' }; + return Manager.AsteriskVersion.ASTERISK_14; + } + else if (version.StartsWith("15.")) + { + VAR_DELIMITER = new char[] { ',' }; + return Manager.AsteriskVersion.ASTERISK_15; + } + else if (version.StartsWith("16.")) + { + VAR_DELIMITER = new char[] { ',' }; + return Manager.AsteriskVersion.ASTERISK_16; + } + else if (version.StartsWith("17.")) + { + VAR_DELIMITER = new char[] { ',' }; + return Manager.AsteriskVersion.ASTERISK_17; + } + else if (version.IndexOf('.') >= 2) + { + VAR_DELIMITER = new char[] { ',' }; + return Manager.AsteriskVersion.ASTERISK_Newer; + } + else + throw new ManagerException("Unknown Asterisk version " + version); } } } @@ -1697,7 +1722,10 @@ namespace AsterNET.Manager string line1; line1 = (string)showVersionFilesResult[0]; if (line1 != null && line1.StartsWith("File")) + { + VAR_DELIMITER = new char[] { '|' }; return AsteriskVersion.ASTERISK_1_2; + } } } return AsteriskVersion.ASTERISK_1_0;