diff --git a/Asterisk.2013/Asterisk.NET/AsterNET.csproj b/Asterisk.2013/Asterisk.NET/AsterNET.csproj
index 7796d2e..87e74cc 100644
--- a/Asterisk.2013/Asterisk.NET/AsterNET.csproj
+++ b/Asterisk.2013/Asterisk.NET/AsterNET.csproj
@@ -260,6 +260,7 @@
+
diff --git a/Asterisk.2013/Asterisk.NET/Common.cs b/Asterisk.2013/Asterisk.NET/Common.cs
index 8070fd4..9111467 100644
--- a/Asterisk.2013/Asterisk.NET/Common.cs
+++ b/Asterisk.2013/Asterisk.NET/Common.cs
@@ -1,4 +1,5 @@
using System;
+using System.Collections.Generic;
using System.Globalization;
using System.Text.RegularExpressions;
@@ -25,7 +26,7 @@ namespace AsterNET
public static char[] MINUS_SEPARATOR = {'-'};
public static char INTERNAL_ACTION_ID_DELIMITER = '#';
- /// Variables delimiter
+ [Obsolete("VAR_DELIMITER moved to ManagerConnection", true)]
public static char[] VAR_DELIMITER = {'|'};
public static IFormatProvider CultureInfoEn = new CultureInfo("en-US", false);
diff --git a/Asterisk.2013/Asterisk.NET/Manager/Action/OriginateAction.cs b/Asterisk.2013/Asterisk.NET/Manager/Action/OriginateAction.cs
index 2cc9595..0d2190d 100644
--- a/Asterisk.2013/Asterisk.NET/Manager/Action/OriginateAction.cs
+++ b/Asterisk.2013/Asterisk.NET/Manager/Action/OriginateAction.cs
@@ -22,7 +22,7 @@ namespace AsterNET.Manager.Action
///
///
///
- public class OriginateAction : ManagerActionEvent
+ public class OriginateAction : ManagerActionEvent, IActionVariable
{
private Dictionary variables;
@@ -158,10 +158,12 @@ namespace AsterNET.Manager.Action
/// multiple variable assignments separated by the '|' character.
/// Example: "VAR1=abc|VAR2=def" sets the channel variables VAR1 to "abc" and VAR2 to "def".
///
+
+ [Obsolete("Don't use this anymore - the delimiter is not server context aware", true)]
public string Variable
{
- get { return Helper.JoinVariables(variables, Common.VAR_DELIMITER, "="); }
- set { variables = Helper.ParseVariables(variables, value, Common.VAR_DELIMITER); }
+ get { return null; /* return Helper.JoinVariables(variables, Common.GET_VAR_DELIMITER(this.Server), "="); */ }
+ set { /* variables = Helper.ParseVariables(variables, value, Common.GET_VAR_DELIMITER(this.Server)); */ }
}
#endregion
diff --git a/Asterisk.2013/Asterisk.NET/Manager/Event/AbstractAgentVariables.cs b/Asterisk.2013/Asterisk.NET/Manager/Event/AbstractAgentVariables.cs
index 750b70f..365dc2a 100644
--- a/Asterisk.2013/Asterisk.NET/Manager/Event/AbstractAgentVariables.cs
+++ b/Asterisk.2013/Asterisk.NET/Manager/Event/AbstractAgentVariables.cs
@@ -5,7 +5,7 @@ using System.Collections;
namespace AsterNET.Manager.Event
{
- public abstract class AbstractAgentVariables : ManagerEvent
+ public abstract class AbstractAgentVariables : ManagerEvent, IActionVariable
{
private Dictionary variables;
@@ -18,25 +18,26 @@ namespace AsterNET.Manager.Event
/// Get/Set the variables to set on the queue call in native asterisk format.
/// Example: "VAR1=abc|VAR2=def".
///
- public string Variable
- {
- get { return Helper.JoinVariables(variables, Common.VAR_DELIMITER, "="); }
- set { variables = Helper.ParseVariables(variables, value, Common.VAR_DELIMITER); }
- }
+ [Obsolete("Don't use this anymore - the delimiter is not server context aware", true)]
+ public string Variable
+ {
+ get { return null; /* return Helper.JoinVariables(variables, Common.GET_VAR_DELIMITER(this.Server), "="); */ }
+ set { /* variables = Helper.ParseVariables(variables, value, Common.GET_VAR_DELIMITER(this.Server)); */ }
+ }
#endregion
#region GetVariables()
///
/// Get the variables dictionary to set on the originated call.
///
- public IDictionary GetVariables()
+ public Dictionary GetVariables()
{
return variables;
}
#endregion
- #region SetVariables(IDictionary vars)
- ///
+ #region SetVariables(Dictionary vars)
+ ///
/// Set the variables dictionary to set on the originated call.
///
public void SetVariables(Dictionary vars)
diff --git a/Asterisk.2013/Asterisk.NET/Manager/IActionVariable.cs b/Asterisk.2013/Asterisk.NET/Manager/IActionVariable.cs
new file mode 100644
index 0000000..09b0e66
--- /dev/null
+++ b/Asterisk.2013/Asterisk.NET/Manager/IActionVariable.cs
@@ -0,0 +1,13 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace AsterNET.Manager
+{
+ interface IActionVariable
+ {
+ Dictionary GetVariables();
+ void SetVariables(Dictionary vars);
+ }
+}
diff --git a/Asterisk.2013/Asterisk.NET/Manager/ManagerConnection.cs b/Asterisk.2013/Asterisk.NET/Manager/ManagerConnection.cs
index 3768cf7..0c1eb81 100644
--- a/Asterisk.2013/Asterisk.NET/Manager/ManagerConnection.cs
+++ b/Asterisk.2013/Asterisk.NET/Manager/ManagerConnection.cs
@@ -157,6 +157,8 @@ namespace AsterNET.Manager
/// Default Slow Reconnect interval in milliseconds.
private int reconnectIntervalMax = 10000;
+ public char[] VAR_DELIMITER = { '|' };
+
#endregion
///
@@ -1506,22 +1508,43 @@ namespace AsterNET.Manager
if (m.Groups.Count >= 2)
{
version = m.Groups[1].Value;
- if (version.StartsWith("1.4."))
- return AsteriskVersion.ASTERISK_1_4;
- else if (version.StartsWith("1.6."))
- return Manager.AsteriskVersion.ASTERISK_1_6;
- else if (version.StartsWith("1.8."))
- return Manager.AsteriskVersion.ASTERISK_1_8;
- else if (version.StartsWith("10."))
- return Manager.AsteriskVersion.ASTERISK_10;
- else if (version.StartsWith("11."))
- return Manager.AsteriskVersion.ASTERISK_11;
- else if (version.StartsWith("12."))
- return Manager.AsteriskVersion.ASTERISK_12;
+ 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);
+ }
+ else
+ throw new ManagerException("Unknown Asterisk version " + version);
}
}
}
@@ -2138,6 +2161,12 @@ namespace AsterNET.Manager
sb.Append(string.Concat(name, ": ", valueAsString, Common.LINE_SEPARATOR));
}
+ IActionVariable actionVar = action as IActionVariable;
+ if(actionVar != null && actionVar.GetVariables().Count > 0)
+ {
+ sb.Append(string.Concat("Variable: ", Helper.JoinVariables(actionVar.GetVariables(), VAR_DELIMITER, "="), Common.LINE_SEPARATOR));
+ }
+
sb.Append(Common.LINE_SEPARATOR);
return sb.ToString();
}
diff --git a/Asterisk.2013/Asterisk.NET/Manager/Originate.cs b/Asterisk.2013/Asterisk.NET/Manager/Originate.cs
index e80ed6e..426ff66 100644
--- a/Asterisk.2013/Asterisk.NET/Manager/Originate.cs
+++ b/Asterisk.2013/Asterisk.NET/Manager/Originate.cs
@@ -141,22 +141,6 @@ namespace AsterNET.Manager
#endregion
- #region Variable
-
- ///
- /// Get/Set the variables to set on the originated call.
- /// Variable assignments are of the form "VARNAME=VALUE". You can specify
- /// multiple variable assignments separated by the '|' character.
- /// Example: "VAR1=abc|VAR2=def" sets the channel variables VAR1 to "abc" and VAR2 to "def".
- ///
- public string Variable
- {
- get { return Helper.JoinVariables(variables, Common.VAR_DELIMITER, "="); }
- set { variables = Helper.ParseVariables(variables, value, Common.VAR_DELIMITER); }
- }
-
- #endregion
-
#region GetVariables()
///