Large code cleanup, see change log

This commit is contained in:
skrusty 2015-01-03 15:37:29 +00:00
parent 19d1fdf418
commit ba42c2f06f
141 changed files with 7393 additions and 8578 deletions

View file

@ -1,55 +1,66 @@
using System; using System;
using System.Text.RegularExpressions;
using System.Globalization; using System.Globalization;
using System.Text.RegularExpressions;
namespace AsterNET namespace AsterNET
{ {
public static class Common public static class Common
{ {
#region Manager API Constants #region Manager API Constants
/// <summary> The hostname to use if none is provided.</summary> /// <summary> The hostname to use if none is provided.</summary>
public const string DEFAULT_HOSTNAME = "localhost"; public const string DEFAULT_HOSTNAME = "localhost";
/// <summary> The port to use if none is provided.</summary>
public const int DEFAULT_PORT = 5038;
/// <summary>Line separator</summary>
public const string LINE_SEPARATOR = "\r\n";
public static Regex ASTERISK_VERSION = new Regex("^Asterisk\\s+([0-9]+.[0-9]+.[0-9]+).*", RegexOptions.Compiled | RegexOptions.IgnoreCase); /// <summary> The port to use if none is provided.</summary>
public static Regex SHOW_VERSION_FILES_PATTERN = new Regex("^([\\S]+)\\s+Revision: ([0-9\\.]+)"); public const int DEFAULT_PORT = 5038;
public static char[] RESPONSE_KEY_VALUE_SEPARATOR = new char[] { ':' };
public static char[] MINUS_SEPARATOR = new char[] { '-' };
public static char INTERNAL_ACTION_ID_DELIMITER = '#';
/// <summary> Variables delimiter </summary>
public static char[] VAR_DELIMITER = new char[] { '|' };
public static IFormatProvider CultureInfoEn = new CultureInfo("en-US", false);
#endregion /// <summary>Line separator</summary>
public const string LINE_SEPARATOR = "\r\n";
#region AGI Constants public static Regex ASTERISK_VERSION = new Regex("^Asterisk\\s+([0-9]+.[0-9]+.[0-9]+).*",
RegexOptions.Compiled | RegexOptions.IgnoreCase);
/// <summary> The default AGI bind port. </summary> public static Regex SHOW_VERSION_FILES_PATTERN = new Regex("^([\\S]+)\\s+Revision: ([0-9\\.]+)");
public const int AGI_BIND_PORT = 4573; public static char[] RESPONSE_KEY_VALUE_SEPARATOR = {':'};
/// <summary> The default AGI thread pool size. </summary> public static char[] MINUS_SEPARATOR = {'-'};
public const int AGI_POOL_SIZE = 10; public static char INTERNAL_ACTION_ID_DELIMITER = '#';
/// <summary> The default AGI bind address. </summary>
public const string AGI_BIND_ADDRESS = "0.0.0.0";
public const string AGI_DEFAULT_RESOURCE_BUNDLE_NAME = "fastagi-mapping.resources"; /// <summary> Variables delimiter </summary>
public const string AGI_END_OF_PROPER_USAGE = "520 End of proper usage."; public static char[] VAR_DELIMITER = {'|'};
public const int AGI_DEFAULT_MAX_DIGITS = 1024; public static IFormatProvider CultureInfoEn = new CultureInfo("en-US", false);
public const int AGI_DEFAULT_TIMEOUT = 0;
public static Regex AGI_STATUS_PATTERN = new Regex("^(\\d{3})[ -]", RegexOptions.Compiled); #endregion
public static Regex AGI_RESULT_PATTERN = new Regex("^200 result= *(\\S+)", RegexOptions.Compiled);
public static Regex AGI_PARENTHESIS_PATTERN = new Regex("^200 result=\\S* +\\((.*)\\)", RegexOptions.Compiled);
public static Regex AGI_ADDITIONAL_ATTRIBUTES_PATTERN = new Regex("^200 result=\\S* +(\\(.*\\) )?(.+)$", RegexOptions.Compiled);
public static Regex AGI_ADDITIONAL_ATTRIBUTE_PATTERN = new Regex("(\\S+)=(\\S+)", RegexOptions.Compiled);
public static Regex AGI_SYNOPSIS_PATTERN = new Regex("^\\s*Usage:\\s*(.*)\\s*$", RegexOptions.Compiled);
public static Regex AGI_SCRIPT_PATTERN = new Regex("^([^\\?]*)\\?(.*)$");
public static Regex AGI_PARAMETER_PATTERN = new Regex("^(.*)=(.*)$");
#endregion #region AGI Constants
}
} /// <summary> The default AGI bind port. </summary>
public const int AGI_BIND_PORT = 4573;
/// <summary> The default AGI thread pool size. </summary>
public const int AGI_POOL_SIZE = 10;
/// <summary> The default AGI bind address. </summary>
public const string AGI_BIND_ADDRESS = "0.0.0.0";
public const string AGI_DEFAULT_RESOURCE_BUNDLE_NAME = "fastagi-mapping.resources";
public const string AGI_END_OF_PROPER_USAGE = "520 End of proper usage.";
public const int AGI_DEFAULT_MAX_DIGITS = 1024;
public const int AGI_DEFAULT_TIMEOUT = 0;
public static Regex AGI_STATUS_PATTERN = new Regex("^(\\d{3})[ -]", RegexOptions.Compiled);
public static Regex AGI_RESULT_PATTERN = new Regex("^200 result= *(\\S+)", RegexOptions.Compiled);
public static Regex AGI_PARENTHESIS_PATTERN = new Regex("^200 result=\\S* +\\((.*)\\)", RegexOptions.Compiled);
public static Regex AGI_ADDITIONAL_ATTRIBUTES_PATTERN = new Regex("^200 result=\\S* +(\\(.*\\) )?(.+)$",
RegexOptions.Compiled);
public static Regex AGI_ADDITIONAL_ATTRIBUTE_PATTERN = new Regex("(\\S+)=(\\S+)", RegexOptions.Compiled);
public static Regex AGI_SYNOPSIS_PATTERN = new Regex("^\\s*Usage:\\s*(.*)\\s*$", RegexOptions.Compiled);
public static Regex AGI_SCRIPT_PATTERN = new Regex("^([^\\?]*)\\?(.*)$");
public static Regex AGI_PARAMETER_PATTERN = new Regex("^(.*)=(.*)$");
#endregion
}
}

View file

@ -1,58 +1,61 @@
using AsterNET.FastAGI.Command;
using AsterNET.IO;
namespace AsterNET.FastAGI namespace AsterNET.FastAGI
{ {
/// <summary> /// <summary>
/// Default implementation of the AGIChannel interface. /// Default implementation of the AGIChannel interface.
/// </summary> /// </summary>
public class AGIChannel public class AGIChannel
{ {
private AGIWriter agiWriter; private readonly bool _SC511_CAUSES_EXCEPTION;
private AGIReader agiReader; private readonly bool _SCHANGUP_CAUSES_EXCEPTION;
private AGIReply agiReply; private readonly AGIReader agiReader;
private readonly AGIWriter agiWriter;
private AGIReply agiReply;
private bool _SC511_CAUSES_EXCEPTION = false;
private bool _SCHANGUP_CAUSES_EXCEPTION = false;
public AGIChannel(SocketConnection socket, bool SC511_CAUSES_EXCEPTION, bool SCHANGUP_CAUSES_EXCEPTION)
public AGIChannel(IO.SocketConnection socket, bool SC511_CAUSES_EXCEPTION, bool SCHANGUP_CAUSES_EXCEPTION)
{ {
this.agiWriter = new AGIWriter(socket); agiWriter = new AGIWriter(socket);
this.agiReader = new AGIReader(socket); agiReader = new AGIReader(socket);
this._SC511_CAUSES_EXCEPTION = SC511_CAUSES_EXCEPTION; _SC511_CAUSES_EXCEPTION = SC511_CAUSES_EXCEPTION;
this._SCHANGUP_CAUSES_EXCEPTION = SCHANGUP_CAUSES_EXCEPTION; _SCHANGUP_CAUSES_EXCEPTION = SCHANGUP_CAUSES_EXCEPTION;
} }
public AGIChannel(AGIWriter agiWriter, AGIReader agiReader, bool SC511_CAUSES_EXCEPTION, bool SCHANGUP_CAUSES_EXCEPTION) public AGIChannel(AGIWriter agiWriter, AGIReader agiReader, bool SC511_CAUSES_EXCEPTION,
{ bool SCHANGUP_CAUSES_EXCEPTION)
this.agiWriter = agiWriter; {
this.agiReader = agiReader; this.agiWriter = agiWriter;
this.agiReader = agiReader;
this._SC511_CAUSES_EXCEPTION = SC511_CAUSES_EXCEPTION; _SC511_CAUSES_EXCEPTION = SC511_CAUSES_EXCEPTION;
this._SCHANGUP_CAUSES_EXCEPTION = SCHANGUP_CAUSES_EXCEPTION; _SCHANGUP_CAUSES_EXCEPTION = SCHANGUP_CAUSES_EXCEPTION;
} }
/// <summary> /// <summary>
/// Get last AGI Reply. /// Get last AGI Reply.
/// </summary> /// </summary>
public AGIReply LastReply public AGIReply LastReply
{ {
get { return agiReply; } get { return agiReply; }
} }
public AGIReply SendCommand(Command.AGICommand command) public AGIReply SendCommand(AGICommand command)
{ {
agiWriter.SendCommand(command); agiWriter.SendCommand(command);
agiReply = agiReader.ReadReply(); agiReply = agiReader.ReadReply();
int status = agiReply.GetStatus(); int status = agiReply.GetStatus();
if (status == (int)AGIReplyStatuses.SC_INVALID_OR_UNKNOWN_COMMAND) if (status == (int) AGIReplyStatuses.SC_INVALID_OR_UNKNOWN_COMMAND)
throw new InvalidOrUnknownCommandException(command.BuildCommand()); throw new InvalidOrUnknownCommandException(command.BuildCommand());
else if (status == (int)AGIReplyStatuses.SC_INVALID_COMMAND_SYNTAX) if (status == (int) AGIReplyStatuses.SC_INVALID_COMMAND_SYNTAX)
throw new InvalidCommandSyntaxException(agiReply.GetSynopsis(), agiReply.GetUsage()); throw new InvalidCommandSyntaxException(agiReply.GetSynopsis(), agiReply.GetUsage());
else if (status == (int)AGIReplyStatuses.SC_DEAD_CHANNEL && _SC511_CAUSES_EXCEPTION) if (status == (int) AGIReplyStatuses.SC_DEAD_CHANNEL && _SC511_CAUSES_EXCEPTION)
throw new AGIHangupException(); throw new AGIHangupException();
else if ((status == 0) && agiReply.FirstLine == "HANGUP" && _SCHANGUP_CAUSES_EXCEPTION) if ((status == 0) && agiReply.FirstLine == "HANGUP" && _SCHANGUP_CAUSES_EXCEPTION)
throw new AGIHangupException(); throw new AGIHangupException();
return agiReply; return agiReply;
} }
} }
} }

View file

@ -1,122 +1,126 @@
using System; using System;
using System.IO; using System.IO;
using System.Threading; using System.Threading;
using AsterNET.FastAGI.Command;
using AsterNET.IO;
namespace AsterNET.FastAGI namespace AsterNET.FastAGI
{ {
/// <summary> /// <summary>
/// An AGIConnectionHandler is created and run by the AGIServer whenever a new /// An AGIConnectionHandler is created and run by the AGIServer whenever a new
/// socket connection from an Asterisk Server is received.<br/> /// socket connection from an Asterisk Server is received.<br />
/// It reads the request using an AGIReader and runs the AGIScript configured to /// It reads the request using an AGIReader and runs the AGIScript configured to
/// handle this type of request. Finally it closes the socket connection. /// handle this type of request. Finally it closes the socket connection.
/// </summary> /// </summary>
public class AGIConnectionHandler public class AGIConnectionHandler
{ {
#if LOGGER #if LOGGER
private Logger logger = Logger.Instance(); private readonly Logger logger = Logger.Instance();
#endif #endif
private static readonly LocalDataStoreSlot channel = Thread.AllocateDataSlot(); private static readonly LocalDataStoreSlot _channel = Thread.AllocateDataSlot();
private IO.SocketConnection socket; private readonly SocketConnection socket;
private IMappingStrategy mappingStrategy; private readonly IMappingStrategy mappingStrategy;
private bool _SC511_CAUSES_EXCEPTION = false; private readonly bool _SC511_CAUSES_EXCEPTION;
private bool _SCHANGUP_CAUSES_EXCEPTION = false; private readonly bool _SCHANGUP_CAUSES_EXCEPTION;
#region Channel #region Channel
/// <summary>
/// Returns the AGIChannel associated with the current thread.
/// </summary>
/// <returns>the AGIChannel associated with the current thread or <code>null</code> if none is associated.</returns>
internal static AGIChannel Channel
{
get
{
return (AGIChannel) Thread.GetData(AGIConnectionHandler.channel);
}
}
#endregion
#region AGIConnectionHandler(socket, mappingStrategy) /// <summary>
/// <summary> /// Returns the AGIChannel associated with the current thread.
/// Creates a new AGIConnectionHandler to handle the given socket connection. /// </summary>
/// </summary> /// <returns>the AGIChannel associated with the current thread or <code>null</code> if none is associated.</returns>
/// <param name="socket">the socket connection to handle.</param> internal static AGIChannel Channel
/// <param name="mappingStrategy">the strategy to use to determine which script to run.</param> {
public AGIConnectionHandler(IO.SocketConnection socket, IMappingStrategy mappingStrategy, bool SC511_CAUSES_EXCEPTION, bool SCHANGUP_CAUSES_EXCEPTION) get { return (AGIChannel) Thread.GetData(_channel); }
{ }
this.socket = socket;
this.mappingStrategy = mappingStrategy;
this._SC511_CAUSES_EXCEPTION = SC511_CAUSES_EXCEPTION;
this._SCHANGUP_CAUSES_EXCEPTION = SCHANGUP_CAUSES_EXCEPTION;
}
#endregion
public void Run() #endregion
{
try
{
AGIReader reader = new AGIReader(socket);
AGIWriter writer = new AGIWriter(socket);
AGIRequest request = reader.ReadRequest();
AGIChannel channel = new AGIChannel(writer, reader, this._SC511_CAUSES_EXCEPTION, this._SCHANGUP_CAUSES_EXCEPTION);
AGIScript script = mappingStrategy.DetermineScript(request);
Thread.SetData(AGIConnectionHandler.channel, channel);
if (script != null) #region AGIConnectionHandler(socket, mappingStrategy)
{
/// <summary>
/// Creates a new AGIConnectionHandler to handle the given socket connection.
/// </summary>
/// <param name="socket">the socket connection to handle.</param>
/// <param name="mappingStrategy">the strategy to use to determine which script to run.</param>
public AGIConnectionHandler(SocketConnection socket, IMappingStrategy mappingStrategy,
bool SC511_CAUSES_EXCEPTION, bool SCHANGUP_CAUSES_EXCEPTION)
{
this.socket = socket;
this.mappingStrategy = mappingStrategy;
_SC511_CAUSES_EXCEPTION = SC511_CAUSES_EXCEPTION;
_SCHANGUP_CAUSES_EXCEPTION = SCHANGUP_CAUSES_EXCEPTION;
}
#endregion
public void Run()
{
try
{
var reader = new AGIReader(socket);
var writer = new AGIWriter(socket);
AGIRequest request = reader.ReadRequest();
var channel = new AGIChannel(writer, reader, _SC511_CAUSES_EXCEPTION, _SCHANGUP_CAUSES_EXCEPTION);
AGIScript script = mappingStrategy.DetermineScript(request);
Thread.SetData(_channel, channel);
if (script != null)
{
#if LOGGER #if LOGGER
logger.Info("Begin AGIScript " + script.GetType().FullName + " on " + Thread.CurrentThread.Name); logger.Info("Begin AGIScript " + script.GetType().FullName + " on " + Thread.CurrentThread.Name);
#endif #endif
script.Service(request, channel); script.Service(request, channel);
#if LOGGER #if LOGGER
logger.Info("End AGIScript " + script.GetType().FullName + " on " + Thread.CurrentThread.Name); logger.Info("End AGIScript " + script.GetType().FullName + " on " + Thread.CurrentThread.Name);
#endif #endif
} }
else else
{ {
string error; var error = "No script configured for URL '" + request.RequestURL + "' (script '" + request.Script +
error = "No script configured for URL '" + request.RequestURL + "' (script '" + request.Script + "')"; "')";
channel.SendCommand(new Command.VerboseCommand(error, 1)); channel.SendCommand(new VerboseCommand(error, 1));
#if LOGGER #if LOGGER
logger.Error(error); logger.Error(error);
#endif #endif
} }
} }
catch (AGIHangupException) catch (AGIHangupException)
{ {
} }
catch (IOException) catch (IOException)
{ {
} }
catch (AGIException ex) catch (AGIException ex)
{ {
#if LOGGER #if LOGGER
logger.Error("AGIException while handling request", ex); logger.Error("AGIException while handling request", ex);
#else #else
throw ex; throw ex;
#endif #endif
} }
catch (Exception ex) catch (Exception ex)
{ {
#if LOGGER #if LOGGER
logger.Error("Unexpected Exception while handling request", ex); logger.Error("Unexpected Exception while handling request", ex);
#else #else
throw ex; throw ex;
#endif #endif
} }
Thread.SetData(AGIConnectionHandler.channel, null); Thread.SetData(_channel, null);
try try
{ {
socket.Close(); socket.Close();
} }
#if LOGGER #if LOGGER
catch(IOException ex) catch (IOException ex)
{ {
logger.Error("Error on close socket", ex); logger.Error("Error on close socket", ex);
} }
#else #else
catch { } catch { }
#endif #endif
} }
} }
} }

View file

@ -1,89 +1,90 @@
using System;
using System.IO;
using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO;
using AsterNET.IO;
namespace AsterNET.FastAGI namespace AsterNET.FastAGI
{ {
public class AGIReader public class AGIReader
{ {
#if LOGGER #if LOGGER
private Logger logger = Logger.Instance(); private readonly Logger logger = Logger.Instance();
#endif #endif
private IO.SocketConnection socket; private readonly SocketConnection socket;
public AGIReader(IO.SocketConnection socket)
{
this.socket = socket;
}
public AGIRequest ReadRequest() public AGIReader(SocketConnection socket)
{ {
string line; this.socket = socket;
List<string> lines = new List<string>(); }
try
{ public AGIRequest ReadRequest()
{
var lines = new List<string>();
try
{
#if LOGGER #if LOGGER
logger.Info("AGIReader.ReadRequest():"); logger.Info("AGIReader.ReadRequest():");
#endif #endif
while ((line = socket.ReadLine()) != null) string line;
{ while ((line = socket.ReadLine()) != null)
if (line.Length == 0) {
break; if (line.Length == 0)
lines.Add(line); break;
lines.Add(line);
#if LOGGER #if LOGGER
logger.Info(line); logger.Info(line);
#endif #endif
} }
} }
catch (IOException ex) catch (IOException ex)
{ {
throw new AGINetworkException("Unable to read request from Asterisk: " + ex.Message, ex); throw new AGINetworkException("Unable to read request from Asterisk: " + ex.Message, ex);
} }
AGIRequest request = new AGIRequest(lines); var request = new AGIRequest(lines)
{
LocalAddress = socket.LocalAddress,
LocalPort = socket.LocalPort,
RemoteAddress = socket.RemoteAddress,
RemotePort = socket.RemotePort
};
request.LocalAddress = socket.LocalAddress; return request;
request.LocalPort = socket.LocalPort; }
request.RemoteAddress = socket.RemoteAddress;
request.RemotePort = socket.RemotePort;
return request; public AGIReply ReadReply()
} {
string line;
public AGIReply ReadReply() var badSyntax = ((int) AGIReplyStatuses.SC_INVALID_COMMAND_SYNTAX).ToString();
{
string line;
string badSyntax = ((int)AGIReplyStatuses.SC_INVALID_COMMAND_SYNTAX).ToString();
List<string> lines = new List<string>(); var lines = new List<string>();
try try
{ {
line = socket.ReadLine(); line = socket.ReadLine();
} }
catch (IOException ex) catch (IOException ex)
{ {
throw new AGINetworkException("Unable to read reply from Asterisk: " + ex.Message, ex); throw new AGINetworkException("Unable to read reply from Asterisk: " + ex.Message, ex);
} }
if (line == null) if (line == null)
throw new AGIHangupException(); throw new AGIHangupException();
lines.Add(line); lines.Add(line);
// read synopsis and usage if statuscode is 520 // read synopsis and usage if statuscode is 520
if (line.StartsWith(badSyntax)) if (line.StartsWith(badSyntax))
try try
{ {
while ((line = socket.ReadLine()) != null) while ((line = socket.ReadLine()) != null)
{ {
lines.Add(line); lines.Add(line);
if (line.StartsWith(badSyntax)) if (line.StartsWith(badSyntax))
break; break;
} }
} }
catch (IOException ex) catch (IOException ex)
{ {
throw new AGINetworkException("Unable to read reply from Asterisk: " + ex.Message, ex); throw new AGINetworkException("Unable to read reply from Asterisk: " + ex.Message, ex);
} }
return new AGIReply(lines); return new AGIReply(lines);
} }
} }
} }

View file

@ -1,320 +1,366 @@
using System; using System;
using System.Text;
using System.Text.RegularExpressions;
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
namespace AsterNET.FastAGI namespace AsterNET.FastAGI
{ {
#region Enum - AGIReplyStatuses
public enum AGIReplyStatuses #region Enum - AGIReplyStatuses
{
/// <summary> public enum AGIReplyStatuses
/// Status code (200) indicating Asterisk successfully processed the AGICommand. {
/// </summary>
SC_SUCCESS = 200,
/// <summary>
/// Status code (510) indicating Asterisk was unable to process the
/// AGICommand because there is no command with the given name available.
/// </summary>
SC_INVALID_OR_UNKNOWN_COMMAND = 510,
/// <summary> /// <summary>
/// Status code (511) indicating Asterisk was unable to process the /// Status code (200) indicating Asterisk successfully processed the AGICommand.
/// AGICommand because the channel is dead. /// </summary>
SC_SUCCESS = 200,
/// <summary>
/// Status code (510) indicating Asterisk was unable to process the
/// AGICommand because there is no command with the given name available.
/// </summary>
SC_INVALID_OR_UNKNOWN_COMMAND = 510,
/// <summary>
/// Status code (511) indicating Asterisk was unable to process the
/// AGICommand because the channel is dead.
/// </summary> /// </summary>
SC_DEAD_CHANNEL = 511, SC_DEAD_CHANNEL = 511,
/// <summary>
/// Status code (520) indicating Asterisk was unable to process the
/// AGICommand because the syntax used was not correct. This is most likely
/// due to missing required parameters or additional parameters sent that are
/// not understood.<br/>
/// Ensure proper quoting of the parameters when you receive this status
/// code.
/// </summary>
SC_INVALID_COMMAND_SYNTAX = 520
}
#endregion
/// <summary> /// <summary>
/// Default implementation of the AGIReply interface. /// Status code (520) indicating Asterisk was unable to process the
/// </summary> /// AGICommand because the syntax used was not correct. This is most likely
public class AGIReply /// due to missing required parameters or additional parameters sent that are
{ /// not understood.<br />
#region Variables /// Ensure proper quoting of the parameters when you receive this status
private Match matcher; /// code.
private List<string> lines; /// </summary>
private string firstLine; SC_INVALID_COMMAND_SYNTAX = 520
/// <summary> The result, that is the part directly following the "result=" string.</summary> }
private string result;
/// <summary> The status code.</summary>
private int status;
/// <summary>Additional attributes contained in this reply, for example endpos.</summary>
private Dictionary<string, string> attributes;
/// <summary> The contents of the parenthesis.</summary>
private string extra;
/// <summary> In case of status == 520 (invalid command syntax) this attribute contains the synopsis of the command.</summary>
private string synopsis;
/// <summary> In case of status == 520 (invalid command syntax) this attribute contains the usage of the command.</summary>
private string usage;
private bool extraCreated;
private bool synopsisCreated;
private bool attributesCreated;
private bool resultCreated;
private bool statusCreated;
#endregion
#region Constructor - AGIReply() #endregion
public AGIReply()
{
}
#endregion
#region Constructor - AGIReply(lines) /// <summary>
public AGIReply(List<string> lines) /// Default implementation of the AGIReply interface.
{ /// </summary>
this.lines = lines; public class AGIReply
try {
{ #region Variables
firstLine = lines[0];
}
catch { }
}
#endregion
#region FirstLine private readonly string firstLine;
public string FirstLine private readonly List<string> lines;
{
get { return firstLine; }
}
#endregion
#region Lines /// <summary>Additional attributes contained in this reply, for example endpos.</summary>
public IList Lines private Dictionary<string, string> attributes;
{
get { return lines; }
}
#endregion
#region ResultCode private bool attributesCreated;
/// <summary>
/// Returns the return code (the result as int).
/// </summary>
/// <returns>the return code or -1 if the result is not an int.</returns>
public int ResultCode
{
get
{
string result;
result = GetResult();
if (result == null)
return -1;
try
{
return Int32.Parse(result);
}
catch
{
return -1;
}
}
}
#endregion
#region ResultCodeAsChar /// <summary> The contents of the parenthesis.</summary>
/// <summary> private string extra;
/// Returns the return code as character.
/// </summary>
/// <returns>the return code as character.</returns>
public char ResultCodeAsChar
{
get
{
int resultCode;
resultCode = ResultCode;
if (resultCode < 0)
return (char)(0x0);
return (char)resultCode;
}
}
#endregion
#region Extra private bool extraCreated;
/// <summary> private Match matcher;
/// Returns the text in parenthesis contained in this reply.<br/>
/// The meaning of this property depends on the command sent. Sometimes it
/// contains a flag like "timeout" or "hangup" or - in case of the
/// GetVariableCommand - the value of the variable.
/// </summary>
/// <returns>the text in the parenthesis or <code>null</code> if not set.</returns>
public string Extra
{
get
{
if (GetStatus() != (int)AGIReplyStatuses.SC_SUCCESS)
return null;
if (extraCreated) /// <summary> The result, that is the part directly following the "result=" string.</summary>
return extra; private string result;
matcher = Common.AGI_PARENTHESIS_PATTERN.Match(firstLine); private bool resultCreated;
if (matcher.Success)
extra = matcher.Groups[1].Value;
extraCreated = true; /// <summary> The status code.</summary>
return extra; private int status;
}
}
#endregion
#region GetResult() private bool statusCreated;
/// <summary>
/// Returns the result, that is the part directly following the "result=" string.
/// </summary>
/// <returns>the result.</returns>
public string GetResult()
{
if (resultCreated)
return result;
matcher = Common.AGI_RESULT_PATTERN.Match(firstLine); /// <summary> In case of status == 520 (invalid command syntax) this attribute contains the synopsis of the command.</summary>
if (matcher.Success) private string synopsis;
result = matcher.Groups[1].Value;
resultCreated = true; private bool synopsisCreated;
return result;
}
#endregion
#region GetStatus() /// <summary> In case of status == 520 (invalid command syntax) this attribute contains the usage of the command.</summary>
/// <summary> private string usage;
/// Returns the status code.<br/>
/// Supported status codes are:<br/>
/// 200 Success<br/>
/// 510 Invalid or unknown command<br/>
/// 520 Invalid command syntax<br/>
/// </summary>
/// <returns>the status code.</returns>
public int GetStatus()
{
if (statusCreated)
return status;
matcher = Common.AGI_STATUS_PATTERN.Match(firstLine);
if (matcher.Success)
status = Int32.Parse(matcher.Groups[1].Value);
statusCreated = true;
return status;
}
#endregion
#region GetAttribute(name) #endregion
/// <summary>
/// Returns an additional attribute contained in the reply.<br/>
/// For example the reply to the StreamFileCommand contains an additional
/// endpos attribute indicating the frame where the playback was stopped.
/// This can be retrieved by calling getAttribute("endpos") on the corresponding reply.
/// </summary>
/// <param name="name">the name of the attribute to retrieve. The name is case insensitive.</param>
/// <returns>the value of the attribute or <code>null</code> if it is not set.</returns>
public string GetAttribute(string name)
{
if (GetStatus() != (int)AGIReplyStatuses.SC_SUCCESS)
return null;
if ("result".ToUpper().Equals(name.ToUpper())) #region Constructor - AGIReply()
return GetResult();
if (!attributesCreated) public AGIReply()
{ {
matcher = Common.AGI_ADDITIONAL_ATTRIBUTES_PATTERN.Match(firstLine); }
if (matcher.Success)
{
string s;
Match attributeMatcher;
attributes = new Dictionary<string,string>(); #endregion
s = matcher.Groups[2].Value;
attributeMatcher = Common.AGI_ADDITIONAL_ATTRIBUTE_PATTERN.Match(s);
while (attributeMatcher.Success)
{
string key;
string value_Renamed;
key = attributeMatcher.Groups[1].Value; #region Constructor - AGIReply(lines)
value_Renamed = attributeMatcher.Groups[2].Value;
attributes[key.ToLower(Helper.CultureInfo)] = value_Renamed;
}
}
attributesCreated = true;
}
if (attributes == null || (attributes.Count == 0)) public AGIReply(List<string> lines)
return null; {
this.lines = lines;
try
{
firstLine = lines[0];
}
catch
{
}
}
return (string)attributes[name.ToLower(Helper.CultureInfo)]; #endregion
}
#endregion
#region GetSynopsis() #region FirstLine
/// <summary>
/// Returns the synopsis of the command sent if Asterisk expected a different
/// syntax (getStatus() == SC_INVALID_COMMAND_SYNTAX).
/// </summary>
/// <returns>the synopsis of the command sent, <code>null</code> if there were no syntax errors.</returns>
public string GetSynopsis()
{
if (GetStatus() != (int)AGIReplyStatuses.SC_INVALID_COMMAND_SYNTAX)
return null;
if (!synopsisCreated) public string FirstLine
{ {
if (lines.Count > 1) get { return firstLine; }
{ }
string secondLine;
Match synopsisMatcher;
secondLine = ((string)lines[1]); #endregion
synopsisMatcher = Common.AGI_SYNOPSIS_PATTERN.Match(secondLine);
if (synopsisMatcher.Success)
synopsis = synopsisMatcher.Groups[1].Value;
}
synopsisCreated = true;
StringBuilder sbUsage = new StringBuilder(); #region Lines
string line;
for (int i = 2; i < lines.Count; i++)
{
line = ((string)lines[i]);
if (line == Common.AGI_END_OF_PROPER_USAGE)
break;
sbUsage.Append(line.Trim());
sbUsage.Append(" ");
}
usage = sbUsage.ToString().Trim();
}
return synopsis;
}
#endregion
#region GetUsage() public IList Lines
/// <summary> {
/// Returns the usage of the command sent if Asterisk expected a different get { return lines; }
/// syntax (getStatus() == SC_INVALID_COMMAND_SYNTAX). }
/// </summary>
/// <returns>
/// the usage of the command sent,
/// <code>null</code> if there were no syntax errors.
/// </returns>
public string GetUsage()
{
return usage;
}
#endregion
#region ToString() #endregion
public override string ToString()
{ #region ResultCode
return Helper.ToString(this);
} /// <summary>
#endregion /// Returns the return code (the result as int).
} /// </summary>
} /// <returns>the return code or -1 if the result is not an int.</returns>
public int ResultCode
{
get
{
string result;
result = GetResult();
if (result == null)
return -1;
try
{
return Int32.Parse(result);
}
catch
{
return -1;
}
}
}
#endregion
#region ResultCodeAsChar
/// <summary>
/// Returns the return code as character.
/// </summary>
/// <returns>the return code as character.</returns>
public char ResultCodeAsChar
{
get
{
int resultCode = ResultCode;
if (resultCode < 0)
return (char) (0x0);
return (char) resultCode;
}
}
#endregion
#region Extra
/// <summary>
/// Returns the text in parenthesis contained in this reply.<br />
/// The meaning of this property depends on the command sent. Sometimes it
/// contains a flag like "timeout" or "hangup" or - in case of the
/// GetVariableCommand - the value of the variable.
/// </summary>
/// <returns>the text in the parenthesis or <code>null</code> if not set.</returns>
public string Extra
{
get
{
if (GetStatus() != (int) AGIReplyStatuses.SC_SUCCESS)
return null;
if (extraCreated)
return extra;
matcher = Common.AGI_PARENTHESIS_PATTERN.Match(firstLine);
if (matcher.Success)
extra = matcher.Groups[1].Value;
extraCreated = true;
return extra;
}
}
#endregion
#region GetResult()
/// <summary>
/// Returns the result, that is the part directly following the "result=" string.
/// </summary>
/// <returns>the result.</returns>
public string GetResult()
{
if (resultCreated)
return result;
matcher = Common.AGI_RESULT_PATTERN.Match(firstLine);
if (matcher.Success)
result = matcher.Groups[1].Value;
resultCreated = true;
return result;
}
#endregion
#region GetStatus()
/// <summary>
/// Returns the status code.<br />
/// Supported status codes are:<br />
/// 200 Success<br />
/// 510 Invalid or unknown command<br />
/// 520 Invalid command syntax<br />
/// </summary>
/// <returns>the status code.</returns>
public int GetStatus()
{
if (statusCreated)
return status;
matcher = Common.AGI_STATUS_PATTERN.Match(firstLine);
if (matcher.Success)
status = Int32.Parse(matcher.Groups[1].Value);
statusCreated = true;
return status;
}
#endregion
#region GetAttribute(name)
/// <summary>
/// Returns an additional attribute contained in the reply.<br />
/// For example the reply to the StreamFileCommand contains an additional
/// endpos attribute indicating the frame where the playback was stopped.
/// This can be retrieved by calling getAttribute("endpos") on the corresponding reply.
/// </summary>
/// <param name="name">the name of the attribute to retrieve. The name is case insensitive.</param>
/// <returns>the value of the attribute or <code>null</code> if it is not set.</returns>
public string GetAttribute(string name)
{
if (GetStatus() != (int) AGIReplyStatuses.SC_SUCCESS)
return null;
if ("result".ToUpper().Equals(name.ToUpper()))
return GetResult();
if (!attributesCreated)
{
matcher = Common.AGI_ADDITIONAL_ATTRIBUTES_PATTERN.Match(firstLine);
if (matcher.Success)
{
string s;
Match attributeMatcher;
attributes = new Dictionary<string, string>();
s = matcher.Groups[2].Value;
attributeMatcher = Common.AGI_ADDITIONAL_ATTRIBUTE_PATTERN.Match(s);
while (attributeMatcher.Success)
{
string key;
string value_Renamed;
key = attributeMatcher.Groups[1].Value;
value_Renamed = attributeMatcher.Groups[2].Value;
attributes[key.ToLower(Helper.CultureInfo)] = value_Renamed;
}
}
attributesCreated = true;
}
if (attributes == null || (attributes.Count == 0))
return null;
return attributes[name.ToLower(Helper.CultureInfo)];
}
#endregion
#region GetSynopsis()
/// <summary>
/// Returns the synopsis of the command sent if Asterisk expected a different
/// syntax (getStatus() == SC_INVALID_COMMAND_SYNTAX).
/// </summary>
/// <returns>the synopsis of the command sent, <code>null</code> if there were no syntax errors.</returns>
public string GetSynopsis()
{
if (GetStatus() != (int) AGIReplyStatuses.SC_INVALID_COMMAND_SYNTAX)
return null;
if (!synopsisCreated)
{
if (lines.Count > 1)
{
string secondLine;
Match synopsisMatcher;
secondLine = lines[1];
synopsisMatcher = Common.AGI_SYNOPSIS_PATTERN.Match(secondLine);
if (synopsisMatcher.Success)
synopsis = synopsisMatcher.Groups[1].Value;
}
synopsisCreated = true;
var sbUsage = new StringBuilder();
string line;
for (int i = 2; i < lines.Count; i++)
{
line = lines[i];
if (line == Common.AGI_END_OF_PROPER_USAGE)
break;
sbUsage.Append(line.Trim());
sbUsage.Append(" ");
}
usage = sbUsage.ToString().Trim();
}
return synopsis;
}
#endregion
#region GetUsage()
/// <summary>
/// Returns the usage of the command sent if Asterisk expected a different
/// syntax (getStatus() == SC_INVALID_COMMAND_SYNTAX).
/// </summary>
/// <returns>
/// the usage of the command sent,
/// <code>null</code> if there were no syntax errors.
/// </returns>
public string GetUsage()
{
return usage;
}
#endregion
#region ToString()
public override string ToString()
{
return Helper.ToString(this);
}
#endregion
}
}

File diff suppressed because it is too large Load diff

View file

@ -1,31 +1,33 @@
using System;
using System.IO; using System.IO;
using AsterNET.FastAGI.Command;
using AsterNET.IO;
namespace AsterNET.FastAGI namespace AsterNET.FastAGI
{ {
/// <summary> /// <summary>
/// Default implementation of the AGIWriter interface. /// Default implementation of the AGIWriter interface.
/// </summary> /// </summary>
public class AGIWriter public class AGIWriter
{ {
private IO.SocketConnection socket; private readonly SocketConnection socket;
public AGIWriter(IO.SocketConnection socket) public AGIWriter(SocketConnection socket)
{ {
lock (this) lock (this)
this.socket = socket; this.socket = socket;
} }
public void SendCommand(Command.AGICommand command) public void SendCommand(AGICommand command)
{ {
string buffer = command.BuildCommand() + "\n"; string buffer = command.BuildCommand() + "\n";
try try
{ {
socket.Write(buffer); socket.Write(buffer);
} }
catch (IOException e) catch (IOException e)
{ {
throw new AGINetworkException("Unable to send command to Asterisk: " + e.Message, e); throw new AGINetworkException("Unable to send command to Asterisk: " + e.Message, e);
} }
} }
} }
} }

View file

@ -1,271 +1,308 @@
using AsterNET.FastAGI.MappingStrategies;
using System.IO; using System.IO;
using System.Net; using System.Net;
using System.Text; using System.Text;
using AsterNET.FastAGI.MappingStrategies;
using AsterNET.IO;
using AsterNET.Util;
namespace AsterNET.FastAGI namespace AsterNET.FastAGI
{ {
public class AsteriskFastAGI public class AsteriskFastAGI
{ {
#region Flags #region Flags
/// <summary> /// <summary>
/// If set to true, causes the AGIChannel to throw an exception when a status code of 511 (Channel Dead) is returned. /// If set to true, causes the AGIChannel to throw an exception when a status code of 511 (Channel Dead) is returned.
/// This is set to false by default to maintain backwards compatibility /// This is set to false by default to maintain backwards compatibility
/// </summary> /// </summary>
public bool SC511_CAUSES_EXCEPTION = false; public bool SC511_CAUSES_EXCEPTION = false;
/// <summary> /// <summary>
/// If set to true, causes the AGIChannel to throw an exception when return status is 0 and reply is HANGUP. /// If set to true, causes the AGIChannel to throw an exception when return status is 0 and reply is HANGUP.
/// This is set to false by default to maintain backwards compatibility /// This is set to false by default to maintain backwards compatibility
/// </summary> /// </summary>
public bool SCHANGUP_CAUSES_EXCEPTION = false; public bool SCHANGUP_CAUSES_EXCEPTION = false;
#endregion #endregion
#region Variables #region Variables
#if LOGGER #if LOGGER
private Logger logger = Logger.Instance(); private readonly Logger logger = Logger.Instance();
#endif #endif
private IO.ServerSocket serverSocket; private ServerSocket serverSocket;
/// <summary> The port to listen on.</summary> /// <summary> The port to listen on.</summary>
private int port; private int port;
/// <summary> The address to listen on.</summary>
private string address;
/// <summary>The thread pool that contains the worker threads to process incoming requests.</summary>
private Util.ThreadPool pool;
/// <summary>The number of worker threads in the thread pool. This equals the maximum number of concurrent requests this AGIServer can serve.</summary>
private int poolSize;
/// <summary> True while this server is shut down. </summary>
private bool stopped;
/// <summary>
/// The strategy to use for bind AGIRequests to AGIScripts that serve them.
/// </summary>
private IMappingStrategy mappingStrategy;
private Encoding socketEncoding = Encoding.ASCII;
#endregion
#region PoolSize /// <summary> The address to listen on.</summary>
/// <summary> private readonly string address;
/// Sets the number of worker threads in the thread pool.<br/>
/// This equals the maximum number of concurrent requests this AGIServer can serve.<br/>
/// The default pool size is 10.
/// </summary>
public int PoolSize
{
set { this.poolSize = value; }
}
#endregion
#region BindPort /// <summary>The thread pool that contains the worker threads to process incoming requests.</summary>
/// <summary> private ThreadPool pool;
/// Sets the TCP port to listen on for new connections.<br/>
/// The default bind port is 4573.
/// </summary>
public int BindPort
{
set
{
this.port = value;
}
}
#endregion
#region MappingStrategy /// <summary>
/// <summary> /// The number of worker threads in the thread pool. This equals the maximum number of concurrent requests this
/// Sets the strategy to use for mapping AGIRequests to AGIScripts that serve them.<br/> /// AGIServer can serve.
/// The default mapping is a MappingStrategy. /// </summary>
/// </summary> private int poolSize;
/// <seealso cref="MappingStrategy" />
public IMappingStrategy MappingStrategy
{
set { this.mappingStrategy = value; }
}
#endregion
#region SocketEncoding /// <summary> True while this server is shut down. </summary>
public Encoding SocketEncoding private bool stopped;
{
get { return this.socketEncoding; }
set { this.socketEncoding = value; }
}
#endregion
#region Constructor - AsteriskFastAGI() /// <summary>
/// <summary> /// The strategy to use for bind AGIRequests to AGIScripts that serve them.
/// Creates a new AsteriskFastAGI. /// </summary>
/// </summary> private IMappingStrategy mappingStrategy;
public AsteriskFastAGI()
{
this.address = Common.AGI_BIND_ADDRESS;
this.port = Common.AGI_BIND_PORT;
this.poolSize = Common.AGI_POOL_SIZE;
this.mappingStrategy = new ResourceMappingStrategy();
}
#endregion
#region Constructor - AsteriskFastAGI() private Encoding socketEncoding = Encoding.ASCII;
/// <summary>
/// Creates a new AsteriskFastAGI. #endregion
/// </summary>
public AsteriskFastAGI(string mappingStrategy) #region PoolSize
{
this.address = Common.AGI_BIND_ADDRESS; /// <summary>
this.port = Common.AGI_BIND_PORT; /// Sets the number of worker threads in the thread pool.<br />
this.poolSize = Common.AGI_POOL_SIZE; /// This equals the maximum number of concurrent requests this AGIServer can serve.<br />
this.mappingStrategy = new ResourceMappingStrategy(mappingStrategy); /// The default pool size is 10.
} /// </summary>
#endregion public int PoolSize
{
set { poolSize = value; }
}
#endregion
#region BindPort
/// <summary>
/// Sets the TCP port to listen on for new connections.<br />
/// The default bind port is 4573.
/// </summary>
public int BindPort
{
set { port = value; }
}
#endregion
#region MappingStrategy
/// <summary>
/// Sets the strategy to use for mapping AGIRequests to AGIScripts that serve them.<br />
/// The default mapping is a MappingStrategy.
/// </summary>
/// <seealso cref="MappingStrategy" />
public IMappingStrategy MappingStrategy
{
set { mappingStrategy = value; }
}
#endregion
#region SocketEncoding
public Encoding SocketEncoding
{
get { return socketEncoding; }
set { socketEncoding = value; }
}
#endregion
#region Constructor - AsteriskFastAGI() #region Constructor - AsteriskFastAGI()
/// <summary> /// <summary>
/// Creates a new AsteriskFastAGI. /// Creates a new AsteriskFastAGI.
/// </summary>
public AsteriskFastAGI()
{
address = Common.AGI_BIND_ADDRESS;
port = Common.AGI_BIND_PORT;
poolSize = Common.AGI_POOL_SIZE;
mappingStrategy = new ResourceMappingStrategy();
}
#endregion
#region Constructor - AsteriskFastAGI()
/// <summary>
/// Creates a new AsteriskFastAGI.
/// </summary>
public AsteriskFastAGI(string mappingStrategy)
{
address = Common.AGI_BIND_ADDRESS;
port = Common.AGI_BIND_PORT;
poolSize = Common.AGI_POOL_SIZE;
this.mappingStrategy = new ResourceMappingStrategy(mappingStrategy);
}
#endregion
#region Constructor - AsteriskFastAGI()
/// <summary>
/// Creates a new AsteriskFastAGI.
/// </summary> /// </summary>
public AsteriskFastAGI(IMappingStrategy mappingStrategy) public AsteriskFastAGI(IMappingStrategy mappingStrategy)
{ {
this.address = Common.AGI_BIND_ADDRESS; address = Common.AGI_BIND_ADDRESS;
this.port = Common.AGI_BIND_PORT; port = Common.AGI_BIND_PORT;
this.poolSize = Common.AGI_POOL_SIZE; poolSize = Common.AGI_POOL_SIZE;
this.mappingStrategy = mappingStrategy; this.mappingStrategy = mappingStrategy;
} }
public AsteriskFastAGI(IMappingStrategy mappingStrategy, string ipaddress, int port, int poolSize) public AsteriskFastAGI(IMappingStrategy mappingStrategy, string ipaddress, int port, int poolSize)
{ {
this.address = ipaddress; address = ipaddress;
this.port = port; this.port = port;
this.poolSize = poolSize; this.poolSize = poolSize;
this.mappingStrategy = mappingStrategy; this.mappingStrategy = mappingStrategy;
} }
#endregion #endregion
#region Constructor - AsteriskFastAGI(int port, int poolSize) #region Constructor - AsteriskFastAGI(int port, int poolSize)
/// <summary>
/// Creates a new AsteriskFastAGI.
/// </summary>
/// <param name="port">The port to listen on.</param>
/// <param name="poolSize">The number of worker threads in the thread pool.
/// This equals the maximum number of concurrent requests this AGIServer can serve.</param>
public AsteriskFastAGI(int port, int poolSize)
{
this.address = Common.AGI_BIND_ADDRESS;
this.port = port;
this.poolSize = poolSize;
this.mappingStrategy = new ResourceMappingStrategy();
}
#endregion
#region Constructor - AsteriskFastAGI(string address, int port, int poolSize) /// <summary>
/// <summary> /// Creates a new AsteriskFastAGI.
/// Creates a new AsteriskFastAGI. /// </summary>
/// </summary> /// <param name="port">The port to listen on.</param>
/// <param name="ipaddress">The address to listen on.</param> /// <param name="poolSize">
/// <param name="port">The port to listen on.</param> /// The number of worker threads in the thread pool.
/// <param name="poolSize">The number of worker threads in the thread pool. /// This equals the maximum number of concurrent requests this AGIServer can serve.
/// This equals the maximum number of concurrent requests this AGIServer can serve.</param> /// </param>
public AsteriskFastAGI(string ipaddress, int port, int poolSize) public AsteriskFastAGI(int port, int poolSize)
{ {
this.address = ipaddress; address = Common.AGI_BIND_ADDRESS;
this.port = port; this.port = port;
this.poolSize = poolSize; this.poolSize = poolSize;
this.mappingStrategy = new ResourceMappingStrategy(); mappingStrategy = new ResourceMappingStrategy();
}
#endregion
public AsteriskFastAGI(string ipaddress = Common.AGI_BIND_ADDRESS,
int port = Common.AGI_BIND_PORT,
int poolSize = Common.AGI_POOL_SIZE,
bool sc511_CausesException = false,
bool scHangUp_CausesException = false)
{
this.address = ipaddress;
this.port = port;
this.poolSize = poolSize;
this.mappingStrategy = new ResourceMappingStrategy();
SC511_CAUSES_EXCEPTION = sc511_CausesException;
SCHANGUP_CAUSES_EXCEPTION = scHangUp_CausesException;
} }
#region Start() #endregion
public void Start()
{ #region Constructor - AsteriskFastAGI(string address, int port, int poolSize)
stopped = false;
mappingStrategy.Load(); /// <summary>
pool = new Util.ThreadPool("AGIServer", poolSize); /// Creates a new AsteriskFastAGI.
/// </summary>
/// <param name="ipaddress">The address to listen on.</param>
/// <param name="port">The port to listen on.</param>
/// <param name="poolSize">
/// The number of worker threads in the thread pool.
/// This equals the maximum number of concurrent requests this AGIServer can serve.
/// </param>
public AsteriskFastAGI(string ipaddress, int port, int poolSize)
{
address = ipaddress;
this.port = port;
this.poolSize = poolSize;
mappingStrategy = new ResourceMappingStrategy();
}
#endregion
public AsteriskFastAGI(string ipaddress = Common.AGI_BIND_ADDRESS,
int port = Common.AGI_BIND_PORT,
int poolSize = Common.AGI_POOL_SIZE,
bool sc511_CausesException = false,
bool scHangUp_CausesException = false)
{
address = ipaddress;
this.port = port;
this.poolSize = poolSize;
mappingStrategy = new ResourceMappingStrategy();
SC511_CAUSES_EXCEPTION = sc511_CausesException;
SCHANGUP_CAUSES_EXCEPTION = scHangUp_CausesException;
}
#region Start()
public void Start()
{
stopped = false;
mappingStrategy.Load();
pool = new ThreadPool("AGIServer", poolSize);
#if LOGGER #if LOGGER
logger.Info("Thread pool started."); logger.Info("Thread pool started.");
#endif #endif
try try
{ {
IPAddress ipAddress = IPAddress.Parse(address); var ipAddress = IPAddress.Parse(address);
serverSocket = new IO.ServerSocket(port, ipAddress, this.SocketEncoding); serverSocket = new ServerSocket(port, ipAddress, SocketEncoding);
} }
catch(IOException ex) catch (IOException ex)
{ {
#if LOGGER #if LOGGER
logger.Error("Unable start AGI Server: cannot to bind to "+ address + ":" + port + ".", ex); logger.Error("Unable start AGI Server: cannot to bind to " + address + ":" + port + ".", ex);
#endif #endif
throw ex; throw ex;
} }
#if LOGGER #if LOGGER
logger.Info("Listening on "+ address + ":" + port + "."); logger.Info("Listening on " + address + ":" + port + ".");
#endif #endif
AGIConnectionHandler connectionHandler; try
IO.SocketConnection socket; {
try SocketConnection socket;
{ while ((socket = serverSocket.Accept()) != null)
while ((socket = serverSocket.Accept()) != null) {
{
#if LOGGER #if LOGGER
logger.Info("Received connection."); logger.Info("Received connection.");
#endif #endif
connectionHandler = new AGIConnectionHandler(socket, mappingStrategy, this.SC511_CAUSES_EXCEPTION, this.SCHANGUP_CAUSES_EXCEPTION); var connectionHandler = new AGIConnectionHandler(socket, mappingStrategy, SC511_CAUSES_EXCEPTION,
pool.AddJob(connectionHandler); SCHANGUP_CAUSES_EXCEPTION);
} pool.AddJob(connectionHandler);
} }
catch (IOException ex) }
{ catch (IOException ex)
if (!stopped) {
{ if (!stopped)
{
#if LOGGER #if LOGGER
logger.Error("IOException while waiting for connections (1).", ex); logger.Error("IOException while waiting for connections (1).", ex);
#endif #endif
throw ex; throw ex;
} }
} }
finally finally
{ {
if (serverSocket != null) if (serverSocket != null)
{ {
try try
{ {
serverSocket.Close(); serverSocket.Close();
} }
#if LOGGER #if LOGGER
catch (IOException ex) catch (IOException ex)
{ {
logger.Error("IOException while waiting for connections (2).", ex); logger.Error("IOException while waiting for connections (2).", ex);
} }
#else #else
catch { } catch { }
#endif #endif
} }
serverSocket = null; serverSocket = null;
pool.Shutdown(); pool.Shutdown();
#if LOGGER #if LOGGER
logger.Info("AGIServer shut down."); logger.Info("AGIServer shut down.");
#endif #endif
} }
} }
#endregion
#region Stop() #endregion
public void Stop()
{ #region Stop()
stopped = true;
if (serverSocket != null) public void Stop()
serverSocket.Close(); {
} stopped = true;
#endregion if (serverSocket != null)
} serverSocket.Close();
} }
#endregion
}
}

View file

@ -1,129 +1,130 @@
using System; using System;
using System.Collections; using System.Collections;
using System.Resources;
using System.Reflection; using System.Reflection;
using System.Resources;
namespace AsterNET.FastAGI namespace AsterNET.FastAGI
{ {
/// <summary> /// <summary>
/// A MappingStrategy that is configured via a resource bundle.<br/> /// A MappingStrategy that is configured via a resource bundle.<br />
/// The resource bundle contains the script part of the url as key and the fully /// The resource bundle contains the script part of the url as key and the fully
/// qualified class name of the corresponding AGIScript as value.<br/> /// qualified class name of the corresponding AGIScript as value.<br />
/// Example: /// Example:
/// <pre> /// <pre>
/// noopcommand = AsterNET.FastAGI.Command.NoopCommand /// noopcommand = AsterNET.FastAGI.Command.NoopCommand
/// </pre> /// </pre>
/// NoopCommand must implement the AGIScript interface and have a default constructor with no parameters.<br/> /// NoopCommand must implement the AGIScript interface and have a default constructor with no parameters.<br />
/// </summary> /// </summary>
[Obsolete("This class has been depreciated in favour of MappingStrategies.ResourceMappingStrategy", false)] [Obsolete("This class has been depreciated in favour of MappingStrategies.ResourceMappingStrategy", false)]
public class MappingStrategy : IMappingStrategy public class MappingStrategy : IMappingStrategy
{ {
#if LOGGER #if LOGGER
private Logger logger = Logger.Instance(); private readonly Logger logger = Logger.Instance();
#endif #endif
private string resourceName; private string resourceName;
private Hashtable mapping; private Hashtable mapping;
public MappingStrategy() public MappingStrategy()
{ {
this.resourceName = Common.AGI_DEFAULT_RESOURCE_BUNDLE_NAME; resourceName = Common.AGI_DEFAULT_RESOURCE_BUNDLE_NAME;
this.mapping = null; mapping = null;
} }
public MappingStrategy(string resourceName) public MappingStrategy(string resourceName)
{ {
this.resourceName = resourceName; this.resourceName = resourceName;
this.mapping = null; mapping = null;
} }
public AGIScript DetermineScript(AGIRequest request) public AGIScript DetermineScript(AGIRequest request)
{ {
AGIScript script = null; AGIScript script = null;
if (mapping != null) if (mapping != null)
lock (mapping.SyncRoot) lock (mapping.SyncRoot)
{ {
if (mapping.Contains(request.Script)) if (mapping.Contains(request.Script))
script = (AGIScript)mapping[request.Script]; script = (AGIScript) mapping[request.Script];
} }
return script; return script;
} }
public string ResourceBundleName public string ResourceBundleName
{ {
set set
{ {
if (value == null) if (value == null)
{ {
mapping = null; mapping = null;
resourceName = null; resourceName = null;
} }
else if (this.resourceName != value) else if (resourceName != value)
{ {
this.resourceName = value; resourceName = value;
Load(); Load();
} }
} }
} }
public void Load() public void Load()
{ {
string scriptName; string scriptName;
string className; string className;
AGIScript agiScript; AGIScript agiScript;
if (mapping == null) if (mapping == null)
mapping = new Hashtable(); mapping = new Hashtable();
lock (mapping) lock (mapping)
{ {
mapping.Clear(); mapping.Clear();
try try
{ {
ResourceReader rr = new ResourceReader(AppDomain.CurrentDomain.BaseDirectory + resourceName); var rr = new ResourceReader(AppDomain.CurrentDomain.BaseDirectory + resourceName);
foreach (DictionaryEntry de in rr) foreach (DictionaryEntry de in rr)
{ {
scriptName = (string)de.Key; scriptName = (string) de.Key;
className = (string)de.Value; className = (string) de.Value;
agiScript = CreateAGIScriptInstance(className); agiScript = CreateAGIScriptInstance(className);
if(mapping.Contains(scriptName)) if (mapping.Contains(scriptName))
throw new AGIException(String.Format("Duplicate mapping name '{0}' in file {1}", scriptName, resourceName)); throw new AGIException(String.Format("Duplicate mapping name '{0}' in file {1}", scriptName,
mapping.Add(scriptName, agiScript); resourceName));
mapping.Add(scriptName, agiScript);
#if LOGGER #if LOGGER
logger.Info("Added mapping for '" + scriptName + "' to class " + agiScript.GetType().FullName); logger.Info("Added mapping for '" + scriptName + "' to class " + agiScript.GetType().FullName);
#endif #endif
} }
} }
catch (Exception ex) catch (Exception ex)
{ {
#if LOGGER #if LOGGER
logger.Error("Resource bundle '" + resourceName + "' is missing."); logger.Error("Resource bundle '" + resourceName + "' is missing.");
#endif #endif
throw ex; throw ex;
} }
} }
} }
private AGIScript CreateAGIScriptInstance(string className) private AGIScript CreateAGIScriptInstance(string className)
{ {
Type agiScriptClass; Type agiScriptClass;
ConstructorInfo constructor; ConstructorInfo constructor;
AGIScript agiScript; AGIScript agiScript;
try try
{ {
agiScriptClass = Type.GetType(className); agiScriptClass = Type.GetType(className);
constructor = agiScriptClass.GetConstructor(new Type[]{}); constructor = agiScriptClass.GetConstructor(new Type[] {});
agiScript = (AGIScript) constructor.Invoke(new object[]{}); agiScript = (AGIScript) constructor.Invoke(new object[] {});
} }
catch(Exception ex) catch (Exception ex)
{ {
#if LOGGER #if LOGGER
logger.Error("Unable to create AGIScript instance of type " + className, ex); logger.Error("Unable to create AGIScript instance of type " + className, ex);
return null; return null;
#else #else
throw new AGIException("Unable to create AGIScript instance of type " + className, ex); throw new AGIException("Unable to create AGIScript instance of type " + className, ex);
#endif #endif
} }
return agiScript; return agiScript;
} }
} }
} }

File diff suppressed because it is too large Load diff

View file

@ -1,16 +1,11 @@
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Text;
namespace AsterNET namespace AsterNET
{ {
internal interface IParseSupport internal interface IParseSupport
{ {
Dictionary<string, string> Attributes Dictionary<string, string> Attributes { get; }
{ bool Parse(string key, string value);
get; Dictionary<string, string> ParseSpecial(Dictionary<string, string> attributes);
} }
bool Parse(string key, string value); }
Dictionary<string, string> ParseSpecial(Dictionary<string, string> attributes);
}
}

View file

@ -1,261 +1,284 @@
using System; using System;
using System.Diagnostics;
using System.Threading;
using System.Text;
using System.Collections; using System.Collections;
using System.Diagnostics;
using System.Reflection;
using System.Threading;
namespace AsterNET namespace AsterNET
{ {
#if LOGGER #if LOGGER
#region class LogFactory #region class LogFactory
/// <summary>
/// Facade to hide details of the underlying logging system.
/// </summary>
public sealed class Logger
{
private static Logger logger;
/// <summary> /// <summary>
/// Returns an instance of Log suitable for logging from the given class. /// Facade to hide details of the underlying logging system.
/// </summary> /// </summary>
/// <returns> the created logger.</returns> public sealed class Logger
public static Logger Instance() {
{ public enum MessageLevel
if(logger == null) {
logger = new Logger(); Info,
return logger; Warning,
} Error,
Debug
}
public enum MessageLevel private static Logger logger;
{
Info,
Warning,
Error,
Debug
}
/// <summary>
/// Creates a new CommonsLoggingLog obtained from commons-logging's LogFactory for the given class.
/// </summary>
public Logger()
{
}
private void writeLine(string type, string msg)
{
System.Diagnostics.Debug.Print(string.Format("{0}[{1}] {2}", type, Thread.CurrentThread.Name, msg));
}
private void writeLine(string msg)
{
System.Diagnostics.Debug.Print(msg);
}
// Max 2 calls from original caller !
private string debugInfo()
{
System.Diagnostics.StackFrame sf = new System.Diagnostics.StackFrame(2, true);
System.Reflection.MethodBase mb = sf.GetMethod();
return string.Concat(mb.DeclaringType.Name, ":", mb.Name);
}
Hashtable visibleDebug = new Hashtable(); private Hashtable visibleDebug = new Hashtable();
Hashtable visibleError = new Hashtable();
Hashtable visibleInfo = new Hashtable();
Hashtable visibleWarning = new Hashtable();
private bool visibleDebugDef = true; private bool visibleDebugDef = true;
private bool visibleErrorDef = true; private Hashtable visibleError = new Hashtable();
private bool visibleInfoDef = true; private bool visibleErrorDef = true;
private bool visibleWarningDef = true; private Hashtable visibleInfo = new Hashtable();
private bool visibleInfoDef = true;
private Hashtable visibleWarning = new Hashtable();
private bool visibleWarningDef = true;
/// <summary> /// <summary>
/// Get visibility for message level of class:method /// Creates a new CommonsLoggingLog obtained from commons-logging's LogFactory for the given class.
/// </summary> /// </summary>
/// <param name="debugClass">messageType:class:method</param> public Logger()
/// <returns></returns> {
public bool IsVisible(MessageLevel messageLevel, string classMethod) }
{
return isVisible(messageLevel, classMethod.GetHashCode());
}
private bool isVisible(MessageLevel messageLevel, int hash) /// <summary>
{ /// Returns an instance of Log suitable for logging from the given class.
switch (messageLevel) /// </summary>
{ /// <returns> the created logger.</returns>
case MessageLevel.Debug: public static Logger Instance()
return (visibleDebug.ContainsKey(hash) ? (bool)visibleDebug[hash] : visibleDebugDef); {
case MessageLevel.Error: if (logger == null)
return (visibleError.ContainsKey(hash) ? (bool)visibleError[hash] : visibleErrorDef); logger = new Logger();
case MessageLevel.Info: return logger;
return (visibleInfo.ContainsKey(hash) ? (bool)visibleInfo[hash] : visibleInfoDef); }
case MessageLevel.Warning:
return (visibleWarning.ContainsKey(hash) ? (bool)visibleWarning[hash] : visibleWarningDef);
}
return true;
}
/// <summary> private void writeLine(string type, string msg)
/// Set visibility for message level of class:method {
/// </summary> System.Diagnostics.Debug.Print("{0}[{1}] {2}", type, Thread.CurrentThread.Name, msg);
/// <param name="visible">visible</param> }
/// <param name="messageLevel">message level</param>
/// <param name="classMethod">class:method</param>
public void Visible(bool visible, MessageLevel messageLevel, string classMethod)
{
int hash = classMethod.GetHashCode();
switch (messageLevel)
{
case MessageLevel.Debug:
visibleDebug[hash] = visible;
return;
case MessageLevel.Error:
visibleError[hash] = visible;
return;
case MessageLevel.Info:
visibleInfo[hash] = visible;
return;
case MessageLevel.Warning:
visibleWarning[hash] = visible;
return;
}
}
/// <summary> private void writeLine(string msg)
/// Set visibility for message level of class:method {
/// </summary> System.Diagnostics.Debug.Print(msg);
/// <param name="visible">visible</param> }
/// <param name="messageLevel">message level</param>
/// <param name="classMethod">class:method</param>
public void Visible(bool visible, MessageLevel messageLevel)
{
switch (messageLevel)
{
case MessageLevel.Debug:
visibleDebugDef = visible;
return;
case MessageLevel.Error:
visibleErrorDef = visible;
return;
case MessageLevel.Info:
visibleInfoDef = visible;
return;
case MessageLevel.Warning:
visibleWarningDef = visible;
return;
}
}
#region Debug // Max 2 calls from original caller !
public void Debug(object o) private string debugInfo()
{ {
string caller = debugInfo(); var sf = new StackFrame(2, true);
if (isVisible(MessageLevel.Debug, caller.GetHashCode())) MethodBase mb = sf.GetMethod();
writeLine(" Debug:", string.Concat(caller, " - ", o.ToString())); return string.Concat(mb.DeclaringType.Name, ":", mb.Name);
} }
public void Debug(string msg)
{
string caller = debugInfo();
if (isVisible(MessageLevel.Debug, caller.GetHashCode()))
writeLine(" Debug:", string.Concat(caller, " - ", msg));
}
public void Debug(string format, params object[] args)
{
string caller = debugInfo();
if (isVisible(MessageLevel.Debug, caller.GetHashCode()))
writeLine(" Debug:", string.Concat(caller, " - ", string.Format(format, args)));
}
public void Debug(string msg, Exception ex)
{
string caller = debugInfo();
if (isVisible(MessageLevel.Debug, caller.GetHashCode()))
writeLine(" Debug:", string.Concat(caller, " - ", string.Format("{0}\n{1}", msg, ex)));
}
#endregion
#region Info /// <summary>
public void Info(object o) /// Get visibility for message level of class:method
{ /// </summary>
string caller = debugInfo(); /// <param name="debugClass">messageType:class:method</param>
if (isVisible(MessageLevel.Info, caller.GetHashCode())) /// <returns></returns>
writeLine(" Info:", string.Concat(caller, " - ", o.ToString())); public bool IsVisible(MessageLevel messageLevel, string classMethod)
} {
public void Info(string msg) return isVisible(messageLevel, classMethod.GetHashCode());
{ }
string caller = debugInfo();
if (isVisible(MessageLevel.Info, caller.GetHashCode()))
writeLine(" Info:", string.Concat(caller, " - ", msg));
}
public void Info(string format, params object[] args)
{
string caller = debugInfo();
if (isVisible(MessageLevel.Info, caller.GetHashCode()))
writeLine(" Info:", string.Concat(caller, " - ", string.Format(format, args)));
}
public void Info(string msg, Exception ex)
{
string caller = debugInfo();
if (isVisible(MessageLevel.Info, caller.GetHashCode()))
writeLine(" Info:", string.Concat(caller, " - ", string.Format("{0}\n{1}", msg, ex)));
}
#endregion
#region Warning private bool isVisible(MessageLevel messageLevel, int hash)
public void Warning(object o) {
{ switch (messageLevel)
string caller = debugInfo(); {
if (isVisible(MessageLevel.Warning, caller.GetHashCode())) case MessageLevel.Debug:
writeLine("Warning:", string.Concat(caller, " - ", o.ToString())); return (visibleDebug.ContainsKey(hash) ? (bool) visibleDebug[hash] : visibleDebugDef);
} case MessageLevel.Error:
public void Warning(string msg) return (visibleError.ContainsKey(hash) ? (bool) visibleError[hash] : visibleErrorDef);
{ case MessageLevel.Info:
string caller = debugInfo(); return (visibleInfo.ContainsKey(hash) ? (bool) visibleInfo[hash] : visibleInfoDef);
if (isVisible(MessageLevel.Warning, caller.GetHashCode())) case MessageLevel.Warning:
writeLine("Warning:", string.Concat(caller, " - ", msg)); return (visibleWarning.ContainsKey(hash) ? (bool) visibleWarning[hash] : visibleWarningDef);
} }
public void Warning(string format, params object[] args) return true;
{ }
string caller = debugInfo();
if (isVisible(MessageLevel.Warning, caller.GetHashCode()))
writeLine("Warning:", string.Concat(caller, " - ", string.Format(format, args)));
}
public void Warning(string msg, Exception ex)
{
string caller = debugInfo();
if (isVisible(MessageLevel.Warning, caller.GetHashCode()))
writeLine("Warning:", string.Concat(caller, " - ", string.Format("{0}\n{1}", msg, ex)));
}
#endregion
#region Error /// <summary>
public void Error(object o) /// Set visibility for message level of class:method
{ /// </summary>
string caller = debugInfo(); /// <param name="visible">visible</param>
if (isVisible(MessageLevel.Error, caller.GetHashCode())) /// <param name="messageLevel">message level</param>
writeLine(" Error:", string.Concat(caller, " - ", o.ToString())); /// <param name="classMethod">class:method</param>
} public void Visible(bool visible, MessageLevel messageLevel, string classMethod)
public void Error(string msg) {
{ int hash = classMethod.GetHashCode();
string caller = debugInfo(); switch (messageLevel)
if (isVisible(MessageLevel.Error, caller.GetHashCode())) {
writeLine(" Error:", string.Concat(caller, " - ", msg)); case MessageLevel.Debug:
} visibleDebug[hash] = visible;
public void Error(string format, params object[] args) return;
{ case MessageLevel.Error:
string caller = debugInfo(); visibleError[hash] = visible;
if (isVisible(MessageLevel.Error, caller.GetHashCode())) return;
writeLine(" Error:", string.Concat(caller, " - ", string.Format(format, args))); case MessageLevel.Info:
} visibleInfo[hash] = visible;
public void Error(string msg, Exception ex) return;
{ case MessageLevel.Warning:
string caller = debugInfo(); visibleWarning[hash] = visible;
if (isVisible(MessageLevel.Error, caller.GetHashCode())) return;
writeLine(" Error:", string.Concat(caller, " - ", string.Format("{0}\n{1}", msg, ex))); }
} }
#endregion
} /// <summary>
#endregion /// Set visibility for message level of class:method
/// </summary>
/// <param name="visible">visible</param>
/// <param name="messageLevel">message level</param>
/// <param name="classMethod">class:method</param>
public void Visible(bool visible, MessageLevel messageLevel)
{
switch (messageLevel)
{
case MessageLevel.Debug:
visibleDebugDef = visible;
return;
case MessageLevel.Error:
visibleErrorDef = visible;
return;
case MessageLevel.Info:
visibleInfoDef = visible;
return;
case MessageLevel.Warning:
visibleWarningDef = visible;
return;
}
}
#region Debug
public void Debug(object o)
{
string caller = debugInfo();
if (isVisible(MessageLevel.Debug, caller.GetHashCode()))
writeLine(" Debug:", string.Concat(caller, " - ", o.ToString()));
}
public void Debug(string msg)
{
string caller = debugInfo();
if (isVisible(MessageLevel.Debug, caller.GetHashCode()))
writeLine(" Debug:", string.Concat(caller, " - ", msg));
}
public void Debug(string format, params object[] args)
{
string caller = debugInfo();
if (isVisible(MessageLevel.Debug, caller.GetHashCode()))
writeLine(" Debug:", string.Concat(caller, " - ", string.Format(format, args)));
}
public void Debug(string msg, Exception ex)
{
string caller = debugInfo();
if (isVisible(MessageLevel.Debug, caller.GetHashCode()))
writeLine(" Debug:", string.Concat(caller, " - ", string.Format("{0}\n{1}", msg, ex)));
}
#endregion
#region Info
public void Info(object o)
{
string caller = debugInfo();
if (isVisible(MessageLevel.Info, caller.GetHashCode()))
writeLine(" Info:", string.Concat(caller, " - ", o.ToString()));
}
public void Info(string msg)
{
string caller = debugInfo();
if (isVisible(MessageLevel.Info, caller.GetHashCode()))
writeLine(" Info:", string.Concat(caller, " - ", msg));
}
public void Info(string format, params object[] args)
{
string caller = debugInfo();
if (isVisible(MessageLevel.Info, caller.GetHashCode()))
writeLine(" Info:", string.Concat(caller, " - ", string.Format(format, args)));
}
public void Info(string msg, Exception ex)
{
string caller = debugInfo();
if (isVisible(MessageLevel.Info, caller.GetHashCode()))
writeLine(" Info:", string.Concat(caller, " - ", string.Format("{0}\n{1}", msg, ex)));
}
#endregion
#region Warning
public void Warning(object o)
{
string caller = debugInfo();
if (isVisible(MessageLevel.Warning, caller.GetHashCode()))
writeLine("Warning:", string.Concat(caller, " - ", o.ToString()));
}
public void Warning(string msg)
{
string caller = debugInfo();
if (isVisible(MessageLevel.Warning, caller.GetHashCode()))
writeLine("Warning:", string.Concat(caller, " - ", msg));
}
public void Warning(string format, params object[] args)
{
string caller = debugInfo();
if (isVisible(MessageLevel.Warning, caller.GetHashCode()))
writeLine("Warning:", string.Concat(caller, " - ", string.Format(format, args)));
}
public void Warning(string msg, Exception ex)
{
string caller = debugInfo();
if (isVisible(MessageLevel.Warning, caller.GetHashCode()))
writeLine("Warning:", string.Concat(caller, " - ", string.Format("{0}\n{1}", msg, ex)));
}
#endregion
#region Error
public void Error(object o)
{
string caller = debugInfo();
if (isVisible(MessageLevel.Error, caller.GetHashCode()))
writeLine(" Error:", string.Concat(caller, " - ", o.ToString()));
}
public void Error(string msg)
{
string caller = debugInfo();
if (isVisible(MessageLevel.Error, caller.GetHashCode()))
writeLine(" Error:", string.Concat(caller, " - ", msg));
}
public void Error(string format, params object[] args)
{
string caller = debugInfo();
if (isVisible(MessageLevel.Error, caller.GetHashCode()))
writeLine(" Error:", string.Concat(caller, " - ", string.Format(format, args)));
}
public void Error(string msg, Exception ex)
{
string caller = debugInfo();
if (isVisible(MessageLevel.Error, caller.GetHashCode()))
writeLine(" Error:", string.Concat(caller, " - ", string.Format("{0}\n{1}", msg, ex)));
}
#endregion
}
#endregion
#endif #endif
} }

View file

@ -1,30 +1,13 @@
using System; namespace AsterNET.Manager.Action
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AsterNET.Manager.Action
{ {
/// <summary> /// <summary>
/// This action lets you execute any AGI command through the Manager interface /// This action lets you execute any AGI command through the Manager interface
/// For example, check the AsterNET.Test project /// For example, check the AsterNET.Test project
/// </summary> /// </summary>
public class AgiAction : ManagerAction public class AgiAction : ManagerAction
{ {
public string Channel { get; set; }
public string Command { get; set; }
/// <summary> /// <summary>
/// Get the name of this action, i.e. "AGI". /// Creates a new empty AgiAction.
/// </summary>
override public string Action
{
get { return "AGI"; }
}
/// <summary>
/// Creates a new empty AgiAction.
/// </summary> /// </summary>
public AgiAction(string channel, string command) public AgiAction(string channel, string command)
{ {
@ -32,6 +15,15 @@ namespace AsterNET.Manager.Action
Command = command; Command = command;
} }
public string Channel { get; set; }
public string Command { get; set; }
/// <summary>
/// Get the name of this action, i.e. "AGI".
/// </summary>
public override string Action
{
get { return "AGI"; }
}
} }
} }

View file

@ -1,37 +1,16 @@
using System; namespace AsterNET.Manager.Action
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace AsterNET.Manager.Action
{ {
public class AOCMessageAction : ManagerAction public class AOCMessageAction : ManagerAction
{ {
private string _channel;
private string _channelPrefix;
private string _msgType;
private string _chargeType;
private int _unitAmount;
private int _unitType;
private string _currencyName;
private string _currencyAmount;
private string _currencyMultiplier;
private string _totalType;
private string _aocBillingId;
private string _chargingAssociationId;
private string _chargingAssociationNumber;
private string _chargingrAssociationPlan;
/// <summary> /// <summary>
/// Generate an Advice of Charge message on a channel. /// Generate an Advice of Charge message on a channel.
/// </summary> /// </summary>
public AOCMessageAction() public AOCMessageAction()
{ {
} }
/// <summary> /// <summary>
/// Generate an Advice of Charge message on a channel. /// Generate an Advice of Charge message on a channel.
/// </summary> /// </summary>
/// <param name="channel"></param> /// <param name="channel"></param>
/// <param name="channelPrefix"></param> /// <param name="channelPrefix"></param>
@ -47,22 +26,25 @@ namespace AsterNET.Manager.Action
/// <param name="chargingAssociationId"></param> /// <param name="chargingAssociationId"></param>
/// <param name="chargingAssociationNumber"></param> /// <param name="chargingAssociationNumber"></param>
/// <param name="chargingrAssociationPlan"></param> /// <param name="chargingrAssociationPlan"></param>
public AOCMessageAction(string channel, string channelPrefix, string msgType, string chargeType, int unitAmount, int unitType, string currencyName, string currencyAmount, string currencyMultiplier, string totalType, string aocBillingId, string chargingAssociationId, string chargingAssociationNumber, string chargingrAssociationPlan) public AOCMessageAction(string channel, string channelPrefix, string msgType, string chargeType, int unitAmount,
int unitType, string currencyName, string currencyAmount, string currencyMultiplier, string totalType,
string aocBillingId, string chargingAssociationId, string chargingAssociationNumber,
string chargingrAssociationPlan)
{ {
_channel = channel; Channel = channel;
_channelPrefix = channelPrefix; ChannelPrefix = channelPrefix;
_msgType = msgType; MsgType = msgType;
_chargeType = chargeType; ChargeType = chargeType;
_unitAmount = unitAmount; UnitAmount = unitAmount;
_unitType = unitType; UnitType = unitType;
_currencyName = currencyName; CurrencyName = currencyName;
_currencyAmount = currencyAmount; CurrencyAmount = currencyAmount;
_currencyMultiplier = currencyMultiplier; CurrencyMultiplier = currencyMultiplier;
_totalType = totalType; TotalType = totalType;
_aocBillingId = aocBillingId; AocBillingId = aocBillingId;
_chargingAssociationId = chargingAssociationId; ChargingAssociationId = chargingAssociationId;
_chargingAssociationNumber = chargingAssociationNumber; ChargingAssociationNumber = chargingAssociationNumber;
_chargingrAssociationPlan = chargingrAssociationPlan; ChargingrAssociationPlan = chargingrAssociationPlan;
} }
public override string Action public override string Action
@ -70,88 +52,32 @@ namespace AsterNET.Manager.Action
get { return "AOCMessage"; } get { return "AOCMessage"; }
} }
public string Channel public string Channel { get; set; }
{
get { return _channel; }
set { _channel = value; }
}
public string ChannelPrefix public string ChannelPrefix { get; set; }
{
get { return _channelPrefix; }
set { _channelPrefix = value; }
}
public string MsgType public string MsgType { get; set; }
{
get { return _msgType; }
set { _msgType = value; }
}
public string ChargeType public string ChargeType { get; set; }
{
get { return _chargeType; }
set { _chargeType = value; }
}
public int UnitAmount public int UnitAmount { get; set; }
{
get { return _unitAmount; }
set { _unitAmount = value; }
}
public int UnitType public int UnitType { get; set; }
{
get { return _unitType; }
set { _unitType = value; }
}
public string CurrencyName public string CurrencyName { get; set; }
{
get { return _currencyName; }
set { _currencyName = value; }
}
public string CurrencyAmount public string CurrencyAmount { get; set; }
{
get { return _currencyAmount; }
set { _currencyAmount = value; }
}
public string CurrencyMultiplier public string CurrencyMultiplier { get; set; }
{
get { return _currencyMultiplier; }
set { _currencyMultiplier = value; }
}
public string TotalType public string TotalType { get; set; }
{
get { return _totalType; }
set { _totalType = value; }
}
public string AocBillingId public string AocBillingId { get; set; }
{
get { return _aocBillingId; }
set { _aocBillingId = value; }
}
public string ChargingAssociationId public string ChargingAssociationId { get; set; }
{
get { return _chargingAssociationId; }
set { _chargingAssociationId = value; }
}
public string ChargingAssociationNumber public string ChargingAssociationNumber { get; set; }
{
get { return _chargingAssociationNumber; }
set { _chargingAssociationNumber = value; }
}
public string ChargingrAssociationPlan public string ChargingrAssociationPlan { get; set; }
{
get { return _chargingrAssociationPlan; }
set { _chargingrAssociationPlan = value; }
}
} }
} }

View file

@ -1,68 +1,70 @@
using System;
namespace AsterNET.Manager.Action namespace AsterNET.Manager.Action
{ {
/// <summary> /// <summary>
/// The AbsoluteTimeoutAction sets the absolute maximum amount of time permitted for a call on a given channel.<br/> /// The AbsoluteTimeoutAction sets the absolute maximum amount of time permitted for a call on a given channel.<br />
/// Note that the timeout is set from the current time forward, not counting the number of seconds the call has already been up.<br/> /// Note that the timeout is set from the current time forward, not counting the number of seconds the call has already
/// When setting a new timeout all previous absolute timeouts are cancelled.<br/> /// been up.<br />
/// When the timeout is reached the call is returned to the T extension so that /// When setting a new timeout all previous absolute timeouts are cancelled.<br />
/// you can playback an explanatory note to the calling party (the called party will not hear that).<br/> /// When the timeout is reached the call is returned to the T extension so that
/// This action corresponds the the AbsoluteTimeout command used in the dialplan. /// you can playback an explanatory note to the calling party (the called party will not hear that).<br />
/// </summary> /// This action corresponds the the AbsoluteTimeout command used in the dialplan.
public class AbsoluteTimeoutAction : ManagerAction /// </summary>
{ public class AbsoluteTimeoutAction : ManagerAction
private string channel; {
private int timeout; #region AbsoluteTimeoutAction()
#region AbsoluteTimeoutAction() /// <summary>
/// <summary> /// Creates a new empty AbsoluteTimeoutAction.
/// Creates a new empty AbsoluteTimeoutAction. /// </summary>
/// </summary> public AbsoluteTimeoutAction()
public AbsoluteTimeoutAction() {
{ }
}
#endregion
#region AbsoluteTimeoutAction(channel, timeout)
/// <summary>
/// Creates a new AbsoluteTimeoutAction with the given channel and timeout.
/// </summary>
/// <param name="channel">the name of the channel</param>
/// <param name="timeout">the timeout in seconds or 0 to cancel the AbsoluteTimeout</param>
public AbsoluteTimeoutAction(string channel, int timeout)
{
this.channel = channel;
this.timeout = timeout;
}
#endregion
#region Action #endregion
/// <summary>
/// Get the name of this action, i.e. "AbsoluteTimeout". #region AbsoluteTimeoutAction(channel, timeout)
/// </summary>
override public string Action /// <summary>
{ /// Creates a new AbsoluteTimeoutAction with the given channel and timeout.
get { return "AbsoluteTimeout"; } /// </summary>
} /// <param name="channel">the name of the channel</param>
#endregion /// <param name="timeout">the timeout in seconds or 0 to cancel the AbsoluteTimeout</param>
#region Channel public AbsoluteTimeoutAction(string channel, int timeout)
/// <summary> {
/// Get/Set the name of the channel.</summary> Channel = channel;
public string Channel Timeout = timeout;
{ }
get { return channel; }
set { this.channel = value; } #endregion
}
#endregion #region Action
#region Timeout
/// <summary> /// <summary>
/// Get/Set the timeout (in seconds) to set. /// Get the name of this action, i.e. "AbsoluteTimeout".
/// </summary> /// </summary>
public int Timeout public override string Action
{ {
get { return timeout; } get { return "AbsoluteTimeout"; }
set { this.timeout = value; } }
}
#endregion #endregion
}
#region Channel
/// <summary>
/// Get/Set the name of the channel.
/// </summary>
public string Channel { get; set; }
#endregion
#region Timeout
/// <summary>
/// Get/Set the timeout (in seconds) to set.
/// </summary>
public int Timeout { get; set; }
#endregion
}
} }

View file

@ -1,107 +1,85 @@
using System;
namespace AsterNET.Manager.Action namespace AsterNET.Manager.Action
{ {
/// <summary> /// <summary>
/// The AgentCallbackLoginAction sets an agent as logged in with callback.<br/> /// The AgentCallbackLoginAction sets an agent as logged in with callback.<br />
/// You can pass an extentsion (and optionally a context) to specify the /// You can pass an extentsion (and optionally a context) to specify the
/// destination of the callback.<br/> /// destination of the callback.<br />
/// In contrast to the AgentCallbackLogin application that you can use within /// In contrast to the AgentCallbackLogin application that you can use within
/// Asterisk's dialplan, you don't need to know the agent's password when logging /// Asterisk's dialplan, you don't need to know the agent's password when logging
/// in an agent.<br/> /// in an agent.<br />
/// Available since Asterisk 1.2 /// Available since Asterisk 1.2
/// </summary> /// </summary>
public class AgentCallbackLoginAction : ManagerAction public class AgentCallbackLoginAction : ManagerAction
{ {
private string agent; /// <summary>
private string exten; /// Creates a new empty AgentCallbackLoginAction.
private string context; /// </summary>
private bool ackCall; public AgentCallbackLoginAction()
private long wrapupTime; {
}
/// <summary> /// <summary>
/// Get the name of this action, i.e. "AgentCallbackLogin". /// Creates a new AgentCallbackLoginAction, that logs in the given agent at
/// </summary> /// the given callback extension.
override public string Action /// </summary>
{ /// <param name="agent">the name of the agent to log in</param>
get { return "AgentCallbackLogin"; } /// <param name="exten">the extension that is called to connect a queue member with this agent</param>
} public AgentCallbackLoginAction(string agent, string exten)
/// <summary> {
/// Get/Set the name of the agent to log in, for example "1002".<br/> Agent = agent;
/// This is property is mandatory. Exten = exten;
/// </summary> }
public string Agent
{
get { return this.agent; }
set { this.agent = value; }
}
/// <summary>
/// Get/Set the extension to use for callback.<br/>
/// This is property is mandatory.
/// </summary>
public string Exten
{
get { return this.exten; }
set { this.exten = value; }
}
/// <summary>
/// Get/Set the context of the extension to use for callback.
/// </summary>
public string Context
{
get { return this.context; }
set { this.context = value; }
}
/// <summary>
/// Get/Set if an acknowledgement is needed when agent is called back.<br/>
/// <code>true</code> if acknowledgement by '#' is required when agent is called back, <code>false</code> otherwise.
/// This property is optional, it allows you to override the defaults defined in Asterisk's configuration.
/// </summary>
public bool AckCall
{
get { return this.ackCall; }
set { this.ackCall = value; }
}
/// <summary>
/// Returns the minimum amount of time (in milliseconds) after disconnecting before the caller can receive a new call.<br/>
/// This property is optional, it allows you to override the defaults defined in Asterisk's configuration.
/// </summary>
public long WrapupTime
{
get { return this.wrapupTime; }
set { this.wrapupTime = value; }
}
/// <summary> /// <summary>
/// Creates a new empty AgentCallbackLoginAction. /// Creates a new AgentCallbackLoginAction, that logs in the given agent at
/// </summary> /// the given callback extension in the given context.
public AgentCallbackLoginAction() /// </summary>
{ /// <param name="agent">the name of the agent to log in</param>
} /// <param name="exten">the extension that is called to connect a queue member with this agent</param>
/// <param name="context">the context of the extension to use for callback</param>
/// <summary> public AgentCallbackLoginAction(string agent, string exten, string context)
/// Creates a new AgentCallbackLoginAction, that logs in the given agent at : this(agent, exten)
/// the given callback extension. {
/// </summary> Context = context;
/// <param name="agent">the name of the agent to log in</param> }
/// <param name="exten">the extension that is called to connect a queue member with this agent</param>
public AgentCallbackLoginAction(string agent, string exten) /// <summary>
{ /// Get the name of this action, i.e. "AgentCallbackLogin".
this.agent = agent; /// </summary>
this.exten = exten; public override string Action
} {
get { return "AgentCallbackLogin"; }
/// <summary> }
/// Creates a new AgentCallbackLoginAction, that logs in the given agent at
/// the given callback extension in the given context. /// <summary>
/// </summary> /// Get/Set the name of the agent to log in, for example "1002".<br />
/// <param name="agent">the name of the agent to log in</param> /// This is property is mandatory.
/// <param name="exten">the extension that is called to connect a queue member with this agent</param> /// </summary>
/// <param name="context">the context of the extension to use for callback</param> public string Agent { get; set; }
public AgentCallbackLoginAction(string agent, string exten, string context)
: this(agent, exten) /// <summary>
{ /// Get/Set the extension to use for callback.<br />
this.context = context; /// This is property is mandatory.
} /// </summary>
} public string Exten { get; set; }
/// <summary>
/// Get/Set the context of the extension to use for callback.
/// </summary>
public string Context { get; set; }
/// <summary>
/// Get/Set if an acknowledgement is needed when agent is called back.<br />
/// <code>true</code> if acknowledgement by '#' is required when agent is called back, <code>false</code> otherwise.
/// This property is optional, it allows you to override the defaults defined in Asterisk's configuration.
/// </summary>
public bool AckCall { get; set; }
/// <summary>
/// Returns the minimum amount of time (in milliseconds) after disconnecting before the caller can receive a new call.
/// <br />
/// This property is optional, it allows you to override the defaults defined in Asterisk's configuration.
/// </summary>
public long WrapupTime { get; set; }
}
} }

View file

@ -1,94 +1,83 @@
using System;
namespace AsterNET.Manager.Action namespace AsterNET.Manager.Action
{ {
/// <summary> /// <summary>
/// The AgentLogoffAction sets an agent as no longer logged in. /// The AgentLogoffAction sets an agent as no longer logged in.
/// </summary> /// </summary>
public class AgentLogoffAction : ManagerAction public class AgentLogoffAction : ManagerAction
{ {
private string agent; #region Action
private bool soft;
#region Action /// <summary>
/// <summary> /// Returns the name of this action, i.e. "AgentLogoff".
/// Returns the name of this action, i.e. "AgentLogoff". /// </summary>
/// </summary> /// <returns>the name of this action</returns>
/// <returns>the name of this action</returns> public override string Action
override public string Action {
{ get { return "AgentLogoff"; }
get }
{
return "AgentLogoff";
}
}
#endregion
#region Agent #endregion
/// <summary>
/// Returns the name of the agent to log off, for example "1002".
/// </summary>
/// <returns>the name of the agent to log off</returns>
/// <summary> Sets the name of the agent to log off, for example "1002".<br/>
/// This is property is mandatory.
/// </summary>
/// <param name="agent">the name of the agent to log off</param>
public string Agent
{
get
{
return agent;
}
set
{
this.agent = value;
}
} #region Agent
#endregion
#region Soft /// <summary>
/// <summary> /// Returns the name of the agent to log off, for example "1002".
/// Get/Set whether to hangup existing calls or not.<br/> /// </summary>
/// Default is to hangup existing calls on logoff. /// <returns>the name of the agent to log off</returns>
/// </summary> /// <summary>
/// <returns> true if existing calls should not be hung up, false otherwise.<br/> /// Sets the name of the agent to log off, for example "1002".<br />
/// <code>null</code> if default should be used. /// This is property is mandatory.
/// </returns> /// </summary>
public bool Soft /// <param name="agent">the name of the agent to log off</param>
{ public string Agent { get; set; }
get { return soft; }
set { this.soft = value; }
}
#endregion
#region Constructors - AgentLogoffAction() #endregion
/// <summary> Creates a new empty AgentLogoffAction.</summary>
public AgentLogoffAction()
{
}
/// <summary>
/// Creates a new AgentLogoffAction that logs off the given agent
/// </summary>
/// <param name="agent">the name of the agent to log off.</param>
public AgentLogoffAction(string agent)
{
this.agent = agent;
}
#endregion
#region Constructors - AgentLogoffAction(string agent, bool soft) #region Soft
/// <summary>
/// Creates a new AgentLogoffAction that logs off the given agent /// <summary>
/// </summary> /// Get/Set whether to hangup existing calls or not.<br />
/// <param name="agent">the name of the agent to log off.</param> /// Default is to hangup existing calls on logoff.
/// <param name="soft">true if exisiting calls should not be hung up on logout.</param> /// </summary>
public AgentLogoffAction(string agent, bool soft) /// <returns>
: this(agent) /// true if existing calls should not be hung up, false otherwise.<br />
{ /// <code>null</code> if default should be used.
this.soft = soft; /// </returns>
} public bool Soft { get; set; }
#endregion
} #endregion
#region Constructors - AgentLogoffAction()
/// <summary> Creates a new empty AgentLogoffAction.</summary>
public AgentLogoffAction()
{
}
/// <summary>
/// Creates a new AgentLogoffAction that logs off the given agent
/// </summary>
/// <param name="agent">the name of the agent to log off.</param>
public AgentLogoffAction(string agent)
{
Agent = agent;
}
#endregion
#region Constructors - AgentLogoffAction(string agent, bool soft)
/// <summary>
/// Creates a new AgentLogoffAction that logs off the given agent
/// </summary>
/// <param name="agent">the name of the agent to log off.</param>
/// <param name="soft">true if exisiting calls should not be hung up on logout.</param>
public AgentLogoffAction(string agent, bool soft)
: this(agent)
{
Soft = soft;
}
#endregion
}
} }

View file

@ -1,41 +1,41 @@
using System; using System;
using AsterNET.Manager.Event;
namespace AsterNET.Manager.Action namespace AsterNET.Manager.Action
{ {
/// <summary> /// <summary>
/// The AgentsAction requests the state of all agents.<br/> /// The AgentsAction requests the state of all agents.<br />
/// For each agent an AgentsEvent is generated. /// For each agent an AgentsEvent is generated.
/// After the state of all agents has been reported an AgentsCompleteEvent is generated.<br/> /// After the state of all agents has been reported an AgentsCompleteEvent is generated.<br />
/// Available since Asterisk 1.2 /// Available since Asterisk 1.2
/// </summary> /// </summary>
/// <seealso cref="AsterNET.Manager.Event.AgentsEvent" /> /// <seealso cref="AsterNET.Manager.Event.AgentsEvent" />
/// <seealso cref="AsterNET.Manager.Event.AgentsCompleteEvent" /> /// <seealso cref="AsterNET.Manager.Event.AgentsCompleteEvent" />
public class AgentsAction : ManagerActionEvent public class AgentsAction : ManagerActionEvent
{ {
#region Action #region Action
/// <summary>
/// Get the name of this action, i.e. "Agents".
/// </summary>
override public string Action
{
get { return "Agents"; }
}
#endregion
#region ActionCompleteEventClass /// <summary>
public override Type ActionCompleteEventClass() /// Get the name of this action, i.e. "Agents".
{ /// </summary>
return typeof(Event.AgentsCompleteEvent); public override string Action
} {
#endregion get { return "Agents"; }
}
#region AgentsAction() #endregion
/// <summary>
/// Creates a new AgentsAction. #region ActionCompleteEventClass
/// </summary>
public AgentsAction() public override Type ActionCompleteEventClass()
{ {
} return typeof (AgentsCompleteEvent);
#endregion }
}
#endregion
#region AgentsAction()
#endregion
}
} }

View file

@ -1,27 +1,16 @@
using System; namespace AsterNET.Manager.Action
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace AsterNET.Manager.Action
{ {
public class AtxferAction : ManagerAction public class AtxferAction : ManagerAction
{ {
private string _channel;
private string _exten;
private string _context;
private string _priority;
/// <summary> /// <summary>
/// Attended transfer. /// Attended transfer.
/// </summary> /// </summary>
public AtxferAction() public AtxferAction()
{ {
} }
/// <summary> /// <summary>
/// Attended transfer. /// Attended transfer.
/// </summary> /// </summary>
/// <param name="channel">Transferer's channel.</param> /// <param name="channel">Transferer's channel.</param>
/// <param name="exten">Extension to transfer to.</param> /// <param name="exten">Extension to transfer to.</param>
@ -29,10 +18,10 @@ namespace AsterNET.Manager.Action
/// <param name="priority">Priority to transfer to.</param> /// <param name="priority">Priority to transfer to.</param>
public AtxferAction(string channel, string exten, string context, string priority) public AtxferAction(string channel, string exten, string context, string priority)
{ {
_channel = channel; Channel = channel;
_exten = exten; Exten = exten;
_context = context; Context = context;
_priority = priority; Priority = priority;
} }
public override string Action public override string Action
@ -41,39 +30,23 @@ namespace AsterNET.Manager.Action
} }
/// <summary> /// <summary>
/// Transferer's channel. /// Transferer's channel.
/// </summary> /// </summary>
public string Channel public string Channel { get; set; }
{
get { return _channel; }
set { _channel = value; }
}
/// <summary> /// <summary>
/// Extension to transfer to. /// Extension to transfer to.
/// </summary> /// </summary>
public string Exten public string Exten { get; set; }
{
get { return _exten; }
set { _exten = value; }
}
/// <summary> /// <summary>
/// Context to transfer to. /// Context to transfer to.
/// </summary> /// </summary>
public string Context public string Context { get; set; }
{
get { return _context; }
set { _context = value; }
}
/// <summary> /// <summary>
/// Priority to transfer to. /// Priority to transfer to.
/// </summary> /// </summary>
public string Priority public string Priority { get; set; }
{
get { return _priority; }
set { _priority = value; }
}
} }
} }

View file

@ -1,35 +1,25 @@
using System; namespace AsterNET.Manager.Action
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace AsterNET.Manager.Action
{ {
public class BridgeAction : ManagerAction public class BridgeAction : ManagerAction
{ {
private string _channel1;
private string _channel2;
private string _tone;
/// <summary> /// <summary>
/// Bridge two channels already in the PBX. /// Bridge two channels already in the PBX.
/// </summary> /// </summary>
public BridgeAction() public BridgeAction()
{ {
} }
/// <summary> /// <summary>
/// Bridge two channels already in the PBX. /// Bridge two channels already in the PBX.
/// </summary> /// </summary>
/// <param name="channel1">Channel to Bridge to Channel2</param> /// <param name="channel1">Channel to Bridge to Channel2</param>
/// <param name="channel2">Channel to Bridge to Channel1</param> /// <param name="channel2">Channel to Bridge to Channel1</param>
/// <param name="tone">Play courtesy tone to Channel 2 [yes|no]</param> /// <param name="tone">Play courtesy tone to Channel 2 [yes|no]</param>
public BridgeAction(string channel1, string channel2, string tone) public BridgeAction(string channel1, string channel2, string tone)
{ {
_channel1 = channel1; Channel1 = channel1;
_channel2 = channel2; Channel2 = channel2;
_tone = tone; Tone = tone;
} }
public override string Action public override string Action
@ -37,22 +27,10 @@ namespace AsterNET.Manager.Action
get { return "Bridge"; } get { return "Bridge"; }
} }
public string Channel1 public string Channel1 { get; set; }
{
get { return _channel1; }
set { _channel1 = value; }
}
public string Channel2 public string Channel2 { get; set; }
{
get { return _channel2; }
set { _channel2 = value; }
}
public string Tone public string Tone { get; set; }
{
get { return _tone; }
set { _tone = value; }
}
} }
} }

View file

@ -1,50 +1,43 @@
using System;
namespace AsterNET.Manager.Action namespace AsterNET.Manager.Action
{ {
/// <summary> /// <summary>
/// The ChallengeAction requests a challenge from the server to use when logging /// The ChallengeAction requests a challenge from the server to use when logging
/// in using challenge/response. Sending this action to the asterisk server /// in using challenge/response. Sending this action to the asterisk server
/// results in a ChallengeResponse being received from the server. /// results in a ChallengeResponse being received from the server.
/// </summary> /// </summary>
/// <seealso cref="Manager.Action.LoginAction"/> /// <seealso cref="Manager.Action.LoginAction" />
/// <seealso cref="Manager.Response.ChallengeResponse"/> /// <seealso cref="Manager.Response.ChallengeResponse" />
public class ChallengeAction : ManagerAction public class ChallengeAction : ManagerAction
{ {
private string authType; /// <summary>
/// Creates a new empty ChallengeAction with MD5 algorithm
/// </summary>
public ChallengeAction()
{
AuthType = "MD5";
}
/// <summary> /// <summary>
/// Get the name of this action, i.e. "Challenge". /// Creates a new ChallengeAction that requests a new login challenge for use
/// </summary> /// with the given digest algorithm.
override public string Action /// </summary>
{ /// <param name="authType">the digest alogrithm to use.</param>
get { return "Challenge"; } public ChallengeAction(string authType)
} {
/// <summary> AuthType = authType;
/// Get/Set the digest alogrithm to use. Currently asterisk only supports "MD5". }
/// </summary>
public string AuthType /// <summary>
{ /// Get the name of this action, i.e. "Challenge".
get { return this.authType; } /// </summary>
set { this.authType = value; } public override string Action
} {
get { return "Challenge"; }
/// <summary> }
/// Creates a new empty ChallengeAction with MD5 algorithm
/// </summary> /// <summary>
public ChallengeAction() /// Get/Set the digest alogrithm to use. Currently asterisk only supports "MD5".
{ /// </summary>
this.authType = "MD5"; public string AuthType { get; set; }
} }
/// <summary>
/// Creates a new ChallengeAction that requests a new login challenge for use
/// with the given digest algorithm.
/// </summary>
/// <param name="authType">the digest alogrithm to use.</param>
public ChallengeAction(string authType)
{
this.authType = authType;
}
}
} }

View file

@ -1,69 +1,69 @@
using System;
namespace AsterNET.Manager.Action namespace AsterNET.Manager.Action
{ {
/// <summary> /// <summary>
/// The ChangeMonitorAction changes the monitoring filename of a channel. /// The ChangeMonitorAction changes the monitoring filename of a channel.
/// It has no effect if the channel is not monitored.<br/> /// It has no effect if the channel is not monitored.<br />
/// It is implemented in <code>res/res_monitor.c</code> /// It is implemented in <code>res/res_monitor.c</code>
/// </summary> /// </summary>
public class ChangeMonitorAction : ManagerAction public class ChangeMonitorAction : ManagerAction
{ {
private string channel; #region Action
private string file;
#region Action /// <summary>
/// <summary> /// Get the name of this action, i.e. "ChangeMonitor".
/// Get the name of this action, i.e. "ChangeMonitor". /// </summary>
/// </summary> public override string Action
override public string Action {
{ get { return "ChangeMonitor"; }
get { return "ChangeMonitor"; } }
}
#endregion
#region Channel
/// <summary>
/// Get/Set the name of the monitored channel.<br/>
/// This property is mandatory.
/// </summary>
public string Channel
{
get { return this.channel; }
set { this.channel = value; }
}
#endregion
#region File
/// <summary>
/// Get/Set the name of the file to which the voice data is written.<br/>
/// This property is mandatory.
/// </summary>
public string File
{
get { return this.file; }
set { this.file = value; }
}
#endregion
#region ChangeMonitorAction() #endregion
/// <summary>
/// Creates a new empty ChangeMonitorAction. #region Channel
/// </summary>
public ChangeMonitorAction() /// <summary>
{ /// Get/Set the name of the monitored channel.<br />
} /// This property is mandatory.
#endregion /// </summary>
#region ChangeMonitorAction(string channel, string file) public string Channel { get; set; }
/// <summary>
/// Creates a new ChangeMonitorAction that causes monitoring data for the #endregion
/// given channel to be written to the given file(s).
/// </summary> #region File
/// <param name="channel">the name of the channel that is monitored</param>
/// <param name="file">the (base) name of the file(s) to which the voice data is written</param> /// <summary>
public ChangeMonitorAction(string channel, string file) /// Get/Set the name of the file to which the voice data is written.<br />
{ /// This property is mandatory.
this.channel = channel; /// </summary>
this.file = file; public string File { get; set; }
}
#endregion #endregion
}
#region ChangeMonitorAction()
/// <summary>
/// Creates a new empty ChangeMonitorAction.
/// </summary>
public ChangeMonitorAction()
{
}
#endregion
#region ChangeMonitorAction(string channel, string file)
/// <summary>
/// Creates a new ChangeMonitorAction that causes monitoring data for the
/// given channel to be written to the given file(s).
/// </summary>
/// <param name="channel">the name of the channel that is monitored</param>
/// <param name="file">the (base) name of the file(s) to which the voice data is written</param>
public ChangeMonitorAction(string channel, string file)
{
Channel = channel;
File = file;
}
#endregion
}
} }

View file

@ -1,45 +1,44 @@
using System;
namespace AsterNET.Manager.Action namespace AsterNET.Manager.Action
{ {
/// <summary> /// <summary>
/// The CommandAction sends a command line interface (CLI) command to the asterisk server.<br/> /// The CommandAction sends a command line interface (CLI) command to the asterisk server.<br />
/// For a list of supported commands type <code>help</code> on asterisk's command line. /// For a list of supported commands type <code>help</code> on asterisk's command line.
/// </summary> /// </summary>
public class CommandAction : ManagerAction public class CommandAction : ManagerAction
{ {
protected internal string command; protected internal string command;
/// <summary> /// <summary>
/// Get the name of this action, i.e. "Command". /// Creates a new CommandAction.
/// </summary> /// </summary>
override public string Action public CommandAction()
{ {
get { return "Command"; } }
}
/// <summary> /// <summary>
/// Get/Set the CLI command to send to the asterisk server. /// Creates a new CommandAction with the given command.
/// </summary> /// </summary>
public string Command /// <param name="command">the CLI command to execute.</param>
{ public CommandAction(string command)
get { return this.command; } {
set { this.command = value; } this.command = command;
} }
/// <summary> /// <summary>
/// Creates a new CommandAction. /// Get the name of this action, i.e. "Command".
/// </summary> /// </summary>
public CommandAction() public override string Action
{ {
} get { return "Command"; }
}
/// <summary>
/// Creates a new CommandAction with the given command. /// <summary>
/// </summary> /// Get/Set the CLI command to send to the asterisk server.
/// <param name="command">the CLI command to execute.</param> /// </summary>
public CommandAction(string command) public string Command
{ {
this.command = command; get { return command; }
} set { command = value; }
} }
}
} }

View file

@ -1,36 +1,31 @@
using System; namespace AsterNET.Manager.Action
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AsterNET.Manager.Action
{ {
public class ConfbridgeKickAction : ManagerAction public class ConfbridgeKickAction : ManagerAction
{ {
/// <summary>
/// Removes a specified user from a specified conference.
/// </summary>
public ConfbridgeKickAction()
{
}
/// <summary>
/// Removes a specified user from a specified conference.
/// </summary>
/// <param name="conference"></param>
/// <param name="channel"></param>
public ConfbridgeKickAction(string conference, string channel)
{
Conference = conference;
Channel = channel;
}
public string Conference { get; set; } public string Conference { get; set; }
public string Channel { get; set; } public string Channel { get; set; }
public override string Action public override string Action
{ {
get { return "ConfbridgeKick"; } get { return "ConfbridgeKick"; }
} }
/// <summary>
/// Removes a specified user from a specified conference.
/// </summary>
public ConfbridgeKickAction()
{ }
/// <summary>
/// Removes a specified user from a specified conference.
/// </summary>
/// <param name="conference"></param>
/// <param name="channel"></param>
public ConfbridgeKickAction(string conference, string channel)
{
this.Conference = conference;
this.Channel = channel;
}
} }
} }

View file

@ -1,12 +1,8 @@
using System; using System;
using System.Collections.Generic; using AsterNET.Manager.Event;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AsterNET.Manager.Action namespace AsterNET.Manager.Action
{ {
/* /*
https://wiki.asterisk.org/wiki/display/AST/ConfBridge+10#ConfBridge10-ConfBridgeAsteriskManagerInterface%28AMI%29Events https://wiki.asterisk.org/wiki/display/AST/ConfBridge+10#ConfBridge10-ConfBridgeAsteriskManagerInterface%28AMI%29Events
Action: ConfbridgeList Action: ConfbridgeList
@ -14,30 +10,31 @@ namespace AsterNET.Manager.Action
*/ */
/// <summary> /// <summary>
/// Lists all users in a particular ConfBridge conference. ConfbridgeList will follow as separate events, /// Lists all users in a particular ConfBridge conference. ConfbridgeList will follow as separate events,
/// followed by a final event called ConfbridgeListComplete /// followed by a final event called ConfbridgeListComplete
/// </summary> /// </summary>
public class ConfbridgeListAction : ManagerActionEvent public class ConfbridgeListAction : ManagerActionEvent
{ {
/// <summary>
/// Lists all users in a particular ConfBridge conference. ConfbridgeList will follow as separate events,
/// followed by a final event called ConfbridgeListComplete
/// </summary>
/// <param name="conference"></param>
public ConfbridgeListAction(string conference)
{
Conference = conference;
}
public string Conference { get; set; } public string Conference { get; set; }
public override string Action public override string Action
{ {
get { return "ConfbridgeList"; } get { return "ConfbridgeList"; }
} }
public override Type ActionCompleteEventClass()
{ public override Type ActionCompleteEventClass()
return typeof(Event.ConfbridgeListCompleteEvent); {
} return typeof (ConfbridgeListCompleteEvent);
}
/// <summary>
/// Lists all users in a particular ConfBridge conference. ConfbridgeList will follow as separate events,
/// followed by a final event called ConfbridgeListComplete
/// </summary>
/// <param name="conference"></param>
public ConfbridgeListAction(string conference)
{
this.Conference = conference;
}
} }
} }

View file

@ -1,34 +1,22 @@
using System; using System;
using System.Collections.Generic; using AsterNET.Manager.Event;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AsterNET.Manager.Action namespace AsterNET.Manager.Action
{ {
/// <summary> /// <summary>
/// Lists data about all active conferences. ConfbridgeListRooms will follow as separate events, /// Lists data about all active conferences. ConfbridgeListRooms will follow as separate events,
/// followed by a final event called ConfbridgeListRoomsComplete. /// followed by a final event called ConfbridgeListRoomsComplete.
/// </summary> /// </summary>
public class ConfbridgeListRoomsAction : ManagerActionEvent public class ConfbridgeListRoomsAction : ManagerActionEvent
{ {
public override string Action public override string Action
{ {
get { return "ConfbridgeListRooms"; } get { return "ConfbridgeListRooms"; }
} }
public override Type ActionCompleteEventClass()
{ public override Type ActionCompleteEventClass()
return typeof(Event.ConfbridgeListRoomsCompleteEvent); {
} return typeof (ConfbridgeListRoomsCompleteEvent);
}
/// <summary>
/// Lists data about all active conferences. ConfbridgeListRooms will follow as separate events,
/// followed by a final event called ConfbridgeListRoomsComplete.
/// </summary>
public ConfbridgeListRoomsAction()
{
}
} }
} }

View file

@ -1,33 +1,28 @@
using System; namespace AsterNET.Manager.Action
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AsterNET.Manager.Action
{ {
public class ConfbridgeLockAction : ManagerAction public class ConfbridgeLockAction : ManagerAction
{ {
/// <summary>
/// Locks a specified conference.
/// </summary>
public ConfbridgeLockAction()
{
}
/// <summary>
/// Locks a specified conference.
/// </summary>
/// <param name="conference"></param>
public ConfbridgeLockAction(string conference)
{
Conference = conference;
}
public string Conference { get; set; } public string Conference { get; set; }
public override string Action public override string Action
{ {
get { return "ConfbridgeLock"; } get { return "ConfbridgeLock"; }
} }
/// <summary>
/// Locks a specified conference.
/// </summary>
public ConfbridgeLockAction()
{ }
/// <summary>
/// Locks a specified conference.
/// </summary>
/// <param name="conference"></param>
public ConfbridgeLockAction(string conference)
{
this.Conference = conference;
}
} }
} }

View file

@ -1,36 +1,31 @@
using System; namespace AsterNET.Manager.Action
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AsterNET.Manager.Action
{ {
public class ConfbridgeMuteAction : ManagerAction public class ConfbridgeMuteAction : ManagerAction
{ {
/// <summary>
/// Mutes a specified user in a specified conference.
/// </summary>
public ConfbridgeMuteAction()
{
}
/// <summary>
/// Mutes a specified user in a specified conference.
/// </summary>
/// <param name="conference"></param>
/// <param name="channel"></param>
public ConfbridgeMuteAction(string conference, string channel)
{
Conference = conference;
Channel = channel;
}
public string Conference { get; set; } public string Conference { get; set; }
public string Channel { get; set; } public string Channel { get; set; }
public override string Action public override string Action
{ {
get { return "ConfbridgeMute"; } get { return "ConfbridgeMute"; }
} }
/// <summary>
/// Mutes a specified user in a specified conference.
/// </summary>
public ConfbridgeMuteAction()
{ }
/// <summary>
/// Mutes a specified user in a specified conference.
/// </summary>
/// <param name="conference"></param>
/// <param name="channel"></param>
public ConfbridgeMuteAction(string conference, string channel)
{
this.Conference = conference;
this.Channel = channel;
}
} }
} }

View file

@ -1,35 +1,30 @@
using System; namespace AsterNET.Manager.Action
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AsterNET.Manager.Action
{ {
public class ConfbridgeSetSingleVideoSrcAction : ManagerAction public class ConfbridgeSetSingleVideoSrcAction : ManagerAction
{ {
/// <summary>
/// Stops recording a specified conference.
/// </summary>
public ConfbridgeSetSingleVideoSrcAction()
{
}
/// <summary>
/// Stops recording a specified conference.
/// </summary>
/// <param name="conference"></param>
public ConfbridgeSetSingleVideoSrcAction(string conference, string channel)
{
Conference = conference;
Channel = channel;
}
public string Conference { get; set; } public string Conference { get; set; }
public string Channel { get; set; } public string Channel { get; set; }
public override string Action public override string Action
{ {
get { return "ConfbridgeSetSingleVideoSrc"; } get { return "ConfbridgeSetSingleVideoSrc"; }
} }
/// <summary>
/// Stops recording a specified conference.
/// </summary>
public ConfbridgeSetSingleVideoSrcAction()
{ }
/// <summary>
/// Stops recording a specified conference.
/// </summary>
/// <param name="conference"></param>
public ConfbridgeSetSingleVideoSrcAction(string conference, string channel)
{
this.Conference = conference;
this.Channel = channel;
}
} }
} }

View file

@ -1,39 +1,34 @@
using System; namespace AsterNET.Manager.Action
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AsterNET.Manager.Action
{ {
public class ConfbridgeStartRecordAction : ManagerAction public class ConfbridgeStartRecordAction : ManagerAction
{ {
/// <summary>
/// Starts recording a specified conference, with an optional filename.
/// If recording is already in progress, an error will be returned.
/// If RecordFile is not provided, the default record_file as specified in the conferences Bridge Profile will be used.
/// If record_file is not specified, a file will automatically be generated in Asterisk's monitor directory.
/// </summary>
public ConfbridgeStartRecordAction()
{
}
/// <summary>
/// Starts recording a specified conference, with an optional filename.
/// If recording is already in progress, an error will be returned.
/// If RecordFile is not provided, the default record_file as specified in the conferences Bridge Profile will be used.
/// If record_file is not specified, a file will automatically be generated in Asterisk's monitor directory.
/// </summary>
/// <param name="conference"></param>
public ConfbridgeStartRecordAction(string conference)
{
Conference = conference;
}
public string Conference { get; set; } public string Conference { get; set; }
public override string Action public override string Action
{ {
get { return "ConfbridgeStartRecord"; } get { return "ConfbridgeStartRecord"; }
} }
/// <summary>
/// Starts recording a specified conference, with an optional filename.
/// If recording is already in progress, an error will be returned.
/// If RecordFile is not provided, the default record_file as specified in the conferences Bridge Profile will be used.
/// If record_file is not specified, a file will automatically be generated in Asterisk's monitor directory.
/// </summary>
public ConfbridgeStartRecordAction()
{ }
/// <summary>
/// Starts recording a specified conference, with an optional filename.
/// If recording is already in progress, an error will be returned.
/// If RecordFile is not provided, the default record_file as specified in the conferences Bridge Profile will be used.
/// If record_file is not specified, a file will automatically be generated in Asterisk's monitor directory.
/// </summary>
/// <param name="conference"></param>
public ConfbridgeStartRecordAction(string conference)
{
this.Conference = conference;
}
} }
} }

View file

@ -1,33 +1,28 @@
using System; namespace AsterNET.Manager.Action
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AsterNET.Manager.Action
{ {
public class ConfbridgeStopRecordAction : ManagerAction public class ConfbridgeStopRecordAction : ManagerAction
{ {
/// <summary>
/// Stops recording a specified conference.
/// </summary>
public ConfbridgeStopRecordAction()
{
}
/// <summary>
/// Stops recording a specified conference.
/// </summary>
/// <param name="conference"></param>
public ConfbridgeStopRecordAction(string conference)
{
Conference = conference;
}
public string Conference { get; set; } public string Conference { get; set; }
public override string Action public override string Action
{ {
get { return "ConfbridgeStopRecord"; } get { return "ConfbridgeStopRecord"; }
} }
/// <summary>
/// Stops recording a specified conference.
/// </summary>
public ConfbridgeStopRecordAction()
{ }
/// <summary>
/// Stops recording a specified conference.
/// </summary>
/// <param name="conference"></param>
public ConfbridgeStopRecordAction(string conference)
{
this.Conference = conference;
}
} }
} }

View file

@ -1,33 +1,28 @@
using System; namespace AsterNET.Manager.Action
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AsterNET.Manager.Action
{ {
public class ConfbridgeUnlockAction : ManagerAction public class ConfbridgeUnlockAction : ManagerAction
{ {
/// <summary>
/// Unlocks a specified conference.
/// </summary>
public ConfbridgeUnlockAction()
{
}
/// <summary>
/// Unlocks a specified conference.
/// </summary>
/// <param name="conference"></param>
public ConfbridgeUnlockAction(string conference)
{
Conference = conference;
}
public string Conference { get; set; } public string Conference { get; set; }
public override string Action public override string Action
{ {
get { return "ConfbridgeUnlock"; } get { return "ConfbridgeUnlock"; }
} }
/// <summary>
/// Unlocks a specified conference.
/// </summary>
public ConfbridgeUnlockAction()
{ }
/// <summary>
/// Unlocks a specified conference.
/// </summary>
/// <param name="conference"></param>
public ConfbridgeUnlockAction(string conference)
{
this.Conference = conference;
}
} }
} }

View file

@ -1,36 +1,31 @@
using System; namespace AsterNET.Manager.Action
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AsterNET.Manager.Action
{ {
public class ConfbridgeUnmuteAction : ManagerAction public class ConfbridgeUnmuteAction : ManagerAction
{ {
/// <summary>
/// Unmutes a specified user in a specified conference.
/// </summary>
public ConfbridgeUnmuteAction()
{
}
/// <summary>
/// Unmutes a specified user in a specified conference.
/// </summary>
/// <param name="conference"></param>
/// <param name="channel"></param>
public ConfbridgeUnmuteAction(string conference, string channel)
{
Conference = conference;
Channel = channel;
}
public string Conference { get; set; } public string Conference { get; set; }
public string Channel { get; set; } public string Channel { get; set; }
public override string Action public override string Action
{ {
get { return "ConfbridgeUnmute"; } get { return "ConfbridgeUnmute"; }
} }
/// <summary>
/// Unmutes a specified user in a specified conference.
/// </summary>
public ConfbridgeUnmuteAction()
{ }
/// <summary>
/// Unmutes a specified user in a specified conference.
/// </summary>
/// <param name="conference"></param>
/// <param name="channel"></param>
public ConfbridgeUnmuteAction(string conference, string channel)
{
this.Conference = conference;
this.Channel = channel;
}
} }
} }

View file

@ -1,22 +1,10 @@
using System; namespace AsterNET.Manager.Action
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace AsterNET.Manager.Action
{ {
public class CoreSettingsAction : ManagerAction public class CoreSettingsAction : ManagerAction
{ {
/// <summary>
/// Show PBX core settings (version etc).
/// </summary>
public CoreSettingsAction()
{
}
public override string Action public override string Action
{ {
get { return "CoreSettings"; } get { return "CoreSettings"; }
} }
} }
} }

View file

@ -1,22 +1,10 @@
using System; namespace AsterNET.Manager.Action
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace AsterNET.Manager.Action
{ {
public class CoreShowChannelsAction : ManagerAction public class CoreShowChannelsAction : ManagerAction
{ {
/// <summary>
/// List currently defined channels and some information about them.
/// </summary>
public CoreShowChannelsAction()
{
}
public override string Action public override string Action
{ {
get { return "CoreShowChannels"; } get { return "CoreShowChannels"; }
} }
} }
} }

View file

@ -1,22 +1,10 @@
using System; namespace AsterNET.Manager.Action
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace AsterNET.Manager.Action
{ {
public class CoreStatusAction : ManagerAction public class CoreStatusAction : ManagerAction
{ {
/// <summary>
/// Show PBX core status variables. Query for Core PBX status.
/// </summary>
public CoreStatusAction()
{
}
public override string Action public override string Action
{ {
get { return "CoreStatus"; } get { return "CoreStatus"; }
} }
} }
} }

View file

@ -1,31 +1,25 @@
using System; namespace AsterNET.Manager.Action
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace AsterNET.Manager.Action
{ {
public class CreateConfigAction : ManagerAction public class CreateConfigAction : ManagerAction
{ {
private string _filename;
/// <summary> /// <summary>
/// Creates an empty file in the configuration directory. /// Creates an empty file in the configuration directory.
/// This action will create an empty file in the configuration directory. This action is intended to be used before an UpdateConfig action. /// This action will create an empty file in the configuration directory. This action is intended to be used before an
/// UpdateConfig action.
/// </summary> /// </summary>
public CreateConfigAction() public CreateConfigAction()
{ {
} }
/// <summary> /// <summary>
/// Creates an empty file in the configuration directory. /// Creates an empty file in the configuration directory.
/// This action will create an empty file in the configuration directory. This action is intended to be used before an UpdateConfig action. /// This action will create an empty file in the configuration directory. This action is intended to be used before an
/// UpdateConfig action.
/// </summary> /// </summary>
/// <param name="filename"></param> /// <param name="filename"></param>
public CreateConfigAction(string filename) public CreateConfigAction(string filename)
{ {
_filename = filename; Filename = filename;
} }
public override string Action public override string Action
@ -33,10 +27,6 @@ namespace AsterNET.Manager.Action
get { return "CreateConfig"; } get { return "CreateConfig"; }
} }
public string Filename public string Filename { get; set; }
{
get { return _filename; }
set { _filename = value; }
}
} }
} }

View file

@ -1,54 +1,41 @@
using System; namespace AsterNET.Manager.Action
namespace AsterNET.Manager.Action
{ {
/// <summary> /// <summary>
///
/// </summary> /// </summary>
public class DBDelAction : ManagerAction public class DBDelAction : ManagerAction
{ {
private string family;
private string key;
public override string Action
{
get { return "DBDel"; }
}
/// <summary> /// <summary>
/// Get/Set the the Family of the entry to delete. /// Creates a new empty DBDelAction.
/// </summary>
public string Family
{
get { return family; }
set { this.family = value; }
}
/// <summary>
/// Get/Set the the key of the entry to delete.
/// </summary>
public string Key
{
get { return key; }
set { this.key = value; }
}
/// <summary>
/// Creates a new empty DBDelAction.
/// </summary> /// </summary>
public DBDelAction() public DBDelAction()
{ {
} }
/// <summary> /// <summary>
/// Creates a new DBDelAction that deletes the value of the database entry /// Creates a new DBDelAction that deletes the value of the database entry
/// with the given key in the given family. /// with the given key in the given family.
/// </summary> /// </summary>
/// <param name="family">the family of the key</param> /// <param name="family">the family of the key</param>
/// <param name="key">the key of the entry to retrieve</param> /// <param name="key">the key of the entry to retrieve</param>
public DBDelAction(string family, string key) public DBDelAction(string family, string key)
{ {
this.family = family; Family = family;
this.key = key; Key = key;
} }
public override string Action
{
get { return "DBDel"; }
}
/// <summary>
/// Get/Set the the Family of the entry to delete.
/// </summary>
public string Family { get; set; }
/// <summary>
/// Get/Set the the key of the entry to delete.
/// </summary>
public string Key { get; set; }
} }
} }

View file

@ -1,14 +1,27 @@
using System; namespace AsterNET.Manager.Action
namespace AsterNET.Manager.Action
{ {
/// <summary> /// <summary>
///
/// </summary> /// </summary>
public class DBDelTreeAction : ManagerAction public class DBDelTreeAction : ManagerAction
{ {
private string family; /// <summary>
private string key; /// Creates a new empty DBDelTreeAction.
/// </summary>
public DBDelTreeAction()
{
}
/// <summary>
/// Creates a new DBDelTreeAction that deletes the database true
/// with the given key in the given family.
/// </summary>
/// <param name="family">the family of the key</param>
/// <param name="key">the key of the entry to retrieve</param>
public DBDelTreeAction(string family, string key)
{
Family = family;
Key = key;
}
public override string Action public override string Action
{ {
@ -16,39 +29,13 @@ namespace AsterNET.Manager.Action
} }
/// <summary> /// <summary>
/// Get/Set the the Family of the entry to delete. /// Get/Set the the Family of the entry to delete.
/// </summary> /// </summary>
public string Family public string Family { get; set; }
{
get { return family; }
set { this.family = value; }
}
/// <summary>
/// Get/Set the the key of the entry to delete.
/// </summary>
public string Key
{
get { return key; }
set { this.key = value; }
}
/// <summary> /// <summary>
/// Creates a new empty DBDelTreeAction. /// Get/Set the the key of the entry to delete.
/// </summary> /// </summary>
public DBDelTreeAction() public string Key { get; set; }
{
}
/// <summary>
/// Creates a new DBDelTreeAction that deletes the database true
/// with the given key in the given family.
/// </summary>
/// <param name="family">the family of the key</param>
/// <param name="key">the key of the entry to retrieve</param>
public DBDelTreeAction(string family, string key)
{
this.family = family;
this.key = key;
}
} }
} }

View file

@ -1,67 +1,59 @@
using System; using System;
using AsterNET.Manager.Event;
namespace AsterNET.Manager.Action namespace AsterNET.Manager.Action
{ {
/// <summary>
/// <summary> /// Retrieves an entry in the Asterisk database for a given family and key.<br />
/// Retrieves an entry in the Asterisk database for a given family and key.<br/> /// If an entry is found a DBGetResponseEvent is sent by Asterisk containing the
/// If an entry is found a DBGetResponseEvent is sent by Asterisk containing the /// value, otherwise a ManagerError indicates that no entry matches.
/// value, otherwise a ManagerError indicates that no entry matches. /// </summary>
/// </summary> /// <seealso cref="AsterNET.Manager.Event.DBGetResponseEvent" />
/// <seealso cref="AsterNET.Manager.Event.DBGetResponseEvent" /> public class DBGetAction : ManagerActionEvent
public class DBGetAction : ManagerActionEvent {
{ /// <summary>
private string family; /// Creates a new empty DBGetAction.
private string key; /// </summary>
public DBGetAction()
{
}
public override string Action /// <summary>
{ /// Creates a new DBGetAction that retrieves the value of the database entry
get { return "DBGet"; } /// with the given key in the given family.
} /// </summary>
/// <summary> Returns the family of the key. /// <param name="family">the family of the key</param>
/// /// <param name="key">the key of the entry to retrieve</param>
/// </summary> public DBGetAction(string family, string key)
/// <returns> the family of the key. {
/// </returns> Family = family;
/// <summary> Sets the family of the key. Key = key;
/// }
/// </summary>
/// <param name="family">the family of the key. public override string Action
/// </param> {
public string Family get { return "DBGet"; }
{ }
get { return family; }
set { this.family = value; } /// <summary>
} /// Returns the family of the key.
/// <summary> /// </summary>
/// Get/Set the the key of the entry to retrieve. /// <returns>
/// </summary> /// the family of the key.
public string Key /// </returns>
{ /// <param name="family">
get { return key; } /// the family of the key.
set { this.key = value; } /// </param>
} public string Family { get; set; }
public override Type ActionCompleteEventClass()
{ /// <summary>
return typeof(Event.DBGetResponseEvent); /// Get/Set the the key of the entry to retrieve.
} /// </summary>
public string Key { get; set; }
/// <summary>
/// Creates a new empty DBGetAction. public override Type ActionCompleteEventClass()
/// </summary> {
public DBGetAction() return typeof (DBGetResponseEvent);
{ }
} }
/// <summary>
/// Creates a new DBGetAction that retrieves the value of the database entry
/// with the given key in the given family.
/// </summary>
/// <param name="family">the family of the key</param>
/// <param name="key">the key of the entry to retrieve</param>
public DBGetAction(string family, string key)
{
this.family = family;
this.key = key;
}
}
} }

View file

@ -1,64 +1,49 @@
using System;
namespace AsterNET.Manager.Action namespace AsterNET.Manager.Action
{ {
/// <summary> /// <summary>
/// Adds or updates an entry in the Asterisk database for a given family, key, and value.<br/> /// Adds or updates an entry in the Asterisk database for a given family, key, and value.<br />
/// Available since Asterisk 1.2 /// Available since Asterisk 1.2
/// </summary> /// </summary>
public class DBPutAction : ManagerAction public class DBPutAction : ManagerAction
{ {
private string family; /// <summary>
private string key; /// Creates a new empty DBPutAction.
private string val; /// </summary>
public DBPutAction()
{
}
override public string Action /// <summary>
{ /// Creates a new DBPutAction that sets the value of the database entry with the given key in the given family.
get { return "DBPut"; } /// </summary>
} /// <param name="family">the family of the key</param>
/// <summary> /// <param name="key">the key of the entry to set</param>
/// Get/Set the family of the key to set. /// <param name="val">the value to set</param>
/// </summary> public DBPutAction(string family, string key, string val)
public string Family {
{ Family = family;
get { return this.family; } Key = key;
set { this.family = value; } Val = val;
} }
/// <summary>
/// Get/Set the the key to set. public override string Action
/// </summary> {
public string Key get { return "DBPut"; }
{ }
get { return this.key; }
set { this.key = value; } /// <summary>
} /// Get/Set the family of the key to set.
/// <summary> /// </summary>
/// Get/Set the value to set. public string Family { get; set; }
/// </summary>
public string Val /// <summary>
{ /// Get/Set the the key to set.
get { return val; } /// </summary>
set { this.val = value; } public string Key { get; set; }
}
/// <summary>
/// <summary> /// Get/Set the value to set.
/// Creates a new empty DBPutAction. /// </summary>
/// </summary> public string Val { get; set; }
public DBPutAction() }
{
}
/// <summary>
/// Creates a new DBPutAction that sets the value of the database entry with the given key in the given family.
/// </summary>
/// <param name="family">the family of the key</param>
/// <param name="key">the key of the entry to set</param>
/// <param name="val">the value to set</param>
public DBPutAction(string family, string key, string val)
{
this.family = family;
this.key = key;
this.val = val;
}
}
} }

View file

@ -1,50 +1,44 @@
using System;
namespace AsterNET.Manager.Action namespace AsterNET.Manager.Action
{ {
/// <summary> /// <summary>
/// With the EventsAction you can specify what kind of events should be sent to this manager connection. /// With the EventsAction you can specify what kind of events should be sent to this manager connection.
/// </summary> /// </summary>
public class EventsAction : ManagerAction public class EventsAction : ManagerAction
{ {
private string eventMask; /// <summary>
/// Creates a new empty EventsAction.
/// </summary>
public EventsAction()
{
}
/// <summary> /// <summary>
/// Get the name of this action, i.e. "Events". /// Creates a new EventsAction that applies the given event mask to the current manager connection.
/// </summary> /// </summary>
override public string Action /// <param name="eventMask">
{ /// the event mask.<br />
get { return "Events"; } /// Set to "on" if all events should be send, "off" if not events should be sent
} /// or a combination of "system", "call" and "log" (separated by ',') to specify what kind of events should be sent.
/// <summary> /// </param>
/// Get/Set the event mask.<br/> public EventsAction(string eventMask)
/// Set to "on" if all events should be send, "off" if not events should be {
/// sent or a combination of "system", "call" and "log" (separated by ',') to EventMask = eventMask;
/// specify what kind of events should be sent. }
/// </summary>
public string EventMask /// <summary>
{ /// Get the name of this action, i.e. "Events".
get { return this.eventMask; } /// </summary>
set { this.eventMask = value; } public override string Action
} {
get { return "Events"; }
/// <summary> }
/// Creates a new empty EventsAction.
/// </summary> /// <summary>
public EventsAction() /// Get/Set the event mask.<br />
{ /// Set to "on" if all events should be send, "off" if not events should be
} /// sent or a combination of "system", "call" and "log" (separated by ',') to
/// specify what kind of events should be sent.
/// <summary> /// </summary>
/// Creates a new EventsAction that applies the given event mask to the current manager connection. public string EventMask { get; set; }
/// </summary> }
/// <param name="eventMask">the event mask.<br/>
/// Set to "on" if all events should be send, "off" if not events should be sent
/// or a combination of "system", "call" and "log" (separated by ',') to specify what kind of events should be sent.
/// </param>
public EventsAction(string eventMask)
{
this.eventMask = eventMask;
}
}
} }

View file

@ -1,43 +1,38 @@
using System;
namespace AsterNET.Manager.Action namespace AsterNET.Manager.Action
{ {
/// <summary> /// <summary>
/// The ExtensionStateAction queries the state of an extension in a given context. /// The ExtensionStateAction queries the state of an extension in a given context.
/// </summary> /// </summary>
public class ExtensionStateAction : ManagerAction public class ExtensionStateAction : ManagerAction
{ {
private string exten; #region Action
private string context;
#region Action /// <summary>
/// <summary> /// Get the name of this action, i.e. "ExtensionState".
/// Get the name of this action, i.e. "ExtensionState". /// </summary>
/// </summary> public override string Action
override public string Action {
{ get { return "ExtensionState"; }
get { return "ExtensionState"; } }
}
#endregion #endregion
#region Exten
/// <summary> #region Exten
/// Get/Set the extension to query.
/// </summary> /// <summary>
public string Exten /// Get/Set the extension to query.
{ /// </summary>
get { return exten; } public string Exten { get; set; }
set { this.exten = value; }
} #endregion
#endregion
#region Context #region Context
/// <summary>
/// Get/Set the name of the context that contains the extension to query. /// <summary>
/// </summary> /// Get/Set the name of the context that contains the extension to query.
public string Context /// </summary>
{ public string Context { get; set; }
get { return context; }
set { this.context = value; } #endregion
} }
#endregion
}
} }

View file

@ -1,54 +1,44 @@
using System;
using System.Collections.Generic;
using System.Text;
using AsterNET.Manager.Response; using AsterNET.Manager.Response;
namespace AsterNET.Manager.Action namespace AsterNET.Manager.Action
{ {
/// <summary> /// <summary>
/// The GetConfigAction sends a GetConfig command to the asterisk server. /// The GetConfigAction sends a GetConfig command to the asterisk server.
/// </summary> /// </summary>
public class GetConfigAction : ManagerActionResponse public class GetConfigAction : ManagerActionResponse
{ {
private string filename; /// <summary>
/// Creates a new GetConfigAction.
/// </summary>
public GetConfigAction()
{
}
/// <summary> /// <summary>
/// Creates a new GetConfigAction. /// Get the name of this action.
/// </summary> /// </summary>
public GetConfigAction() /// <param name="filename">the configuration filename.</param>
{ public GetConfigAction(string filename)
} {
Filename = filename;
}
/// <summary> /// <summary>
/// Get the name of this action. /// Get the name of this action.
/// </summary> /// </summary>
public override string Action public override string Action
{ {
get { return "GetConfig"; } get { return "GetConfig"; }
} }
/// <summary> /// <summary>
/// Get the name of this action. /// Get/Set the configuration filename.
/// </summary> /// </summary>
/// <param name="filename">the configuration filename.</param> public string Filename { get; set; }
/// </summary>
public GetConfigAction(string filename)
{
this.filename = filename;
}
/// <summary> public override object ActionCompleteResponseClass()
/// Get/Set the configuration filename. {
/// </summary> return new GetConfigResponse();
public string Filename }
{ }
get { return this.filename; } }
set { this.filename = value; }
}
public override object ActionCompleteResponseClass()
{
return new GetConfigResponse();
}
}
}

View file

@ -1,65 +1,54 @@
using System;
namespace AsterNET.Manager.Action namespace AsterNET.Manager.Action
{ {
/// <summary> /// <summary>
/// The GetVarAction queries for a channel variable. /// The GetVarAction queries for a channel variable.
/// </summary> /// </summary>
public class GetVarAction : ManagerAction public class GetVarAction : ManagerAction
{ {
private string channel; /// <summary>
private string varName; /// Creates a new empty GetVarAction.
/// </summary>
public GetVarAction()
{
}
/// <summary> /// <summary>
/// Creates a new empty GetVarAction. /// Creates a new GetVarAction that queries for the given global variable.
/// </summary> /// </summary>
public GetVarAction() /// <param name="variable">the name of the global variable to query.</param>
{ public GetVarAction(string variable)
} {
Variable = variable;
}
/// <summary> /// <summary>
/// Creates a new GetVarAction that queries for the given global variable. /// Creates a new GetVarAction that queries for the given local channel variable.
/// </summary> /// </summary>
/// <param name="variable">the name of the global variable to query.</param> /// <param name="channel">the name of the channel, for example "SIP/1234-9cd".</param>
public GetVarAction(string variable) /// <param name="variable">the name of the variable to query.</param>
{ public GetVarAction(string channel, string variable)
this.varName = variable; {
} Channel = channel;
Variable = variable;
}
/// <summary> /// <summary>
/// Creates a new GetVarAction that queries for the given local channel variable. /// Get the name of this action, i.e. "GetVar".
/// </summary> /// </summary>
/// <param name="channel">the name of the channel, for example "SIP/1234-9cd".</param> public override string Action
/// <param name="variable">the name of the variable to query.</param> {
public GetVarAction(string channel, string variable) get { return "GetVar"; }
{ }
this.channel = channel;
this.varName = variable;
}
/// <summary> /// <summary>
/// Get the name of this action, i.e. "GetVar". /// Get/Set the name of the channel, if you query for a local channel variable.
/// </summary> /// Leave empty to query for a global variable.
override public string Action /// </summary>
{ public string Channel { get; set; }
get { return "GetVar"; }
} /// <summary>
/// <summary> /// Get/Set the name of the variable to query.
/// Get/Set the name of the channel, if you query for a local channel variable. /// </summary>
/// Leave empty to query for a global variable. public string Variable { get; set; }
/// </summary> }
public string Channel
{
get { return this.channel; }
set { this.channel = value; }
}
/// <summary>
/// Get/Set the name of the variable to query.
/// </summary>
public string Variable
{
get { return this.varName; }
set { this.varName = value; }
}
}
} }

View file

@ -1,44 +1,37 @@
using System;
namespace AsterNET.Manager.Action namespace AsterNET.Manager.Action
{ {
/// <summary> /// <summary>
/// The HangupAction causes the pbx to hang up a given channel. /// The HangupAction causes the pbx to hang up a given channel.
/// </summary> /// </summary>
public class HangupAction : ManagerAction public class HangupAction : ManagerAction
{ {
private string channel; /// <summary>
/// Creates a new empty HangupAction.
/// </summary>
public HangupAction()
{
}
/// <summary> /// <summary>
/// Creates a new empty HangupAction. /// Creates a new HangupAction that hangs up the given channel.
/// </summary> /// </summary>
public HangupAction() /// <param name="channel">the name of the channel to hangup.</param>
{ public HangupAction(string channel)
} {
Channel = channel;
}
/// <summary> /// <summary>
/// Creates a new HangupAction that hangs up the given channel. /// Get the name of this action, i.e. "Hangup".
/// </summary> /// </summary>
/// <param name="channel">the name of the channel to hangup.</param> public override string Action
public HangupAction(string channel) {
{ get { return "Hangup"; }
this.channel = channel; }
}
/// <summary> /// <summary>
/// Get the name of this action, i.e. "Hangup". /// Get/Set the name of the channel to hangup.
/// </summary> /// </summary>
override public string Action public string Channel { get; set; }
{ }
get { return "Hangup"; }
}
/// <summary>
/// Get/Set the name of the channel to hangup.
/// </summary>
public string Channel
{
get { return this.channel; }
set { this.channel = value; }
}
}
} }

View file

@ -1,12 +1,6 @@
using System; namespace AsterNET.Manager.Action
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AsterNET.Manager.Action
{ {
class ListCommandsAction internal class ListCommandsAction
{ {
} }
} }

View file

@ -1,128 +1,113 @@
using System;
namespace AsterNET.Manager.Action namespace AsterNET.Manager.Action
{ {
/// <summary> /// <summary>
/// The LoginAction authenticates the connection.<br/> /// The LoginAction authenticates the connection.<br />
/// A successful login is the precondition for sending any other action except /// A successful login is the precondition for sending any other action except
/// for the ChallengeAction.<br/> /// for the ChallengeAction.<br />
/// An unsuccessful login results in an ManagerError being received from the /// An unsuccessful login results in an ManagerError being received from the
/// server with a message set to "Authentication failed" and the socket being /// server with a message set to "Authentication failed" and the socket being
/// closed by Asterisk. /// closed by Asterisk.
/// </summary> /// </summary>
/// <seealso cref="Manager.Action.ChallengeAction" /> /// <seealso cref="Manager.Action.ChallengeAction" />
/// <seealso cref="Manager.Response.ManagerError" /> /// <seealso cref="Manager.Response.ManagerError" />
public class LoginAction : ManagerAction public class LoginAction : ManagerAction
{ {
private string username; /// <summary>
private string secret; /// Creates a new empty LoginAction.
private string authType; /// </summary>
private string key; public LoginAction()
private string events; {
}
/// <summary> /// <summary>
/// Get the name of this action, i.e. "Login". /// Creates a new LoginAction that performs a cleartext login.<br />
/// </summary> /// You should not use cleartext login if you are concerned about security and login with a password hash instead.
override public string Action /// </summary>
{ /// <param name="username">the username as configured in Asterisk's <code>manager.conf</code></param>
get { return "Login"; } /// <param name="secret">the user's password as configured in Asterisk's <code>manager.conf</code></param>
} /// <seealso cref="Manager.Action.ChallengeAction" />
/// <summary> public LoginAction(string username, string secret)
/// Get/Set the username as configured in asterik's <code>manager.conf</code>.</summary> {
public string Username Username = username;
{ Secret = secret;
get { return this.username; } }
set { this.username = value; }
} /// <summary>
/// <summary> /// Creates a new LoginAction that performs a login via challenge/response.
/// Get/Set the secret to use when using cleartext login.<br/> /// </summary>
/// The secret contains the user's password as configured in Asterisk's <code>manager.conf</code>.<br/> /// <param name="username">the username as configured in Asterisk's <code>manager.conf</code></param>
/// The secret and key properties are mutually exclusive. /// <param name="authType">
/// </summary> /// the digest alogrithm, must match the digest algorithm that was used with the corresponding
public string Secret /// ChallengeAction.
{ /// </param>
get { return this.secret; } /// <param name="key">the hash of the user's password and the challenge</param>
set { this.secret = value; } public LoginAction(string username, string authType, string key)
} {
/// <summary> Username = username;
/// Get/Set the digest alogrithm when using challenge/response.<br/> AuthType = authType;
/// The digest algorithm is used to create the key based on the challenge and Key = key;
/// the user's password.<br/> }
/// Currently Asterisk supports only "MD5".
/// </summary> /// <summary>
public string AuthType /// Creates a new LoginAction that performs a login via challenge/response.
{ /// </summary>
get { return this.authType; } /// <param name="username">the username as configured in Asterisk's <code>manager.conf</code></param>
set { this.authType = value; } /// <param name="authType">
} /// the digest alogrithm, must match the digest algorithm that was used with the corresponding
/// <summary> /// ChallengeAction.
/// Get/Set the key. /// </param>
/// </summary> /// <param name="key">the hash of the user's password and the challenge</param>
public string Key /// <param name="events">
{ /// the event mask.<br />
get { return this.key; } /// Set to "on" if all events should be send, "off" if not events should be sent
set { this.key = value; } /// or a combination of "system", "call" and "log" (separated by ',') to specify what kind of events should be sent.
} /// </param>
/// <summary> public LoginAction(string username, string authType, string key, string events)
/// Get/Set the event mask.<br/> {
/// Set to "on" if all events should be send, "off" if not events should be sent or a combination of Username = username;
/// "system", "call" and "log" (separated by ',') to specify what kind of events should be sent. AuthType = authType;
/// </summary> Key = key;
public string Events Events = events;
{ }
get { return this.events; }
set { this.events = value; } /// <summary>
} /// Get the name of this action, i.e. "Login".
/// </summary>
/// <summary> public override string Action
/// Creates a new empty LoginAction. {
/// </summary> get { return "Login"; }
public LoginAction() }
{
} /// <summary>
/// Get/Set the username as configured in asterik's <code>manager.conf</code>.
/// <summary> /// </summary>
/// Creates a new LoginAction that performs a cleartext login.<br/> public string Username { get; set; }
/// You should not use cleartext login if you are concerned about security and login with a password hash instead.
/// </summary> /// <summary>
/// <param name="username">the username as configured in Asterisk's <code>manager.conf</code></param> /// Get/Set the secret to use when using cleartext login.<br />
/// <param name="secret">the user's password as configured in Asterisk's <code>manager.conf</code></param> /// The secret contains the user's password as configured in Asterisk's <code>manager.conf</code>.<br />
/// <seealso cref="Manager.Action.ChallengeAction" /> /// The secret and key properties are mutually exclusive.
public LoginAction(string username, string secret) /// </summary>
{ public string Secret { get; set; }
this.username = username;
this.secret = secret; /// <summary>
} /// Get/Set the digest alogrithm when using challenge/response.<br />
/// The digest algorithm is used to create the key based on the challenge and
/// <summary> /// the user's password.<br />
/// Creates a new LoginAction that performs a login via challenge/response. /// Currently Asterisk supports only "MD5".
/// </summary> /// </summary>
/// <param name="username">the username as configured in Asterisk's <code>manager.conf</code></param> public string AuthType { get; set; }
/// <param name="authType">the digest alogrithm, must match the digest algorithm that was used with the corresponding ChallengeAction.</param>
/// <param name="key">the hash of the user's password and the challenge</param> /// <summary>
public LoginAction(string username, string authType, string key) /// Get/Set the key.
{ /// </summary>
this.username = username; public string Key { get; set; }
this.authType = authType;
this.key = key; /// <summary>
} /// Get/Set the event mask.<br />
/// Set to "on" if all events should be send, "off" if not events should be sent or a combination of
/// <summary> /// "system", "call" and "log" (separated by ',') to specify what kind of events should be sent.
/// Creates a new LoginAction that performs a login via challenge/response. /// </summary>
/// </summary> public string Events { get; set; }
/// <param name="username">the username as configured in Asterisk's <code>manager.conf</code></param> }
/// <param name="authType">the digest alogrithm, must match the digest algorithm that was used with the corresponding ChallengeAction.</param>
/// <param name="key">the hash of the user's password and the challenge</param>
/// <param name="events">the event mask.<br/>
/// Set to "on" if all events should be send, "off" if not events should be sent
/// or a combination of "system", "call" and "log" (separated by ',') to specify what kind of events should be sent.
/// </param>
public LoginAction(string username, string authType, string key, string events)
{
this.username = username;
this.authType = authType;
this.key = key;
this.events = events;
}
}
} }

View file

@ -1,25 +1,16 @@
using System;
namespace AsterNET.Manager.Action namespace AsterNET.Manager.Action
{ {
/// <summary> /// <summary>
/// The LogoffAction causes the server to close the connection. /// The LogoffAction causes the server to close the connection.
/// </summary> /// </summary>
public class LogoffAction : ManagerAction public class LogoffAction : ManagerAction
{ {
/// <summary> /// <summary>
/// Get the name of this action, i.e. "Logoff". /// Get the name of this action, i.e. "Logoff".
/// </summary> /// </summary>
override public string Action public override string Action
{ {
get { return "Logoff"; } get { return "Logoff"; }
} }
}
/// <summary>
/// Creates a new LogoffAction.
/// </summary>
public LogoffAction()
{
}
}
} }

View file

@ -1,54 +1,48 @@
using System;
namespace AsterNET.Manager.Action namespace AsterNET.Manager.Action
{ {
/// <summary> /// <summary>
/// The MailboxCountAction queries the number of unread and read messages in a mailbox.<br/> /// The MailboxCountAction queries the number of unread and read messages in a mailbox.<br />
/// The MailboxCountAction returns a MailboxStatusResponse. /// The MailboxCountAction returns a MailboxStatusResponse.
/// </summary> /// </summary>
/// <seealso cref="Manager.Response.MailboxCountResponse" /> /// <seealso cref="Manager.Response.MailboxCountResponse" />
public class MailboxCountAction : ManagerAction public class MailboxCountAction : ManagerAction
{ {
private string mailbox; /// <summary>
/// Creates a new empty MailboxCountAction.
/// </summary>
public MailboxCountAction()
{
}
/// <summary> /// <summary>
/// Get the name of this action, i.e. "MailboxCount". /// Creates a new MailboxCountAction that queries the number of unread and
/// </summary> /// read messages in the given mailbox.
override public string Action /// </summary>
{ /// <param name="mailbox">
get { return "MailboxCount"; } /// the name of the mailbox to query.<br />
} /// This can either be only the number of the mailbox or a string
/// <summary> /// of the form mailboxnumber@context.If no context is specified
/// Get/Set the name of the mailbox to query.<br/> /// "default" is assumed.
/// This can either be only the number of the mailbox or a string of the form /// </param>
/// mailboxnumber@context.If no context is specified "default" is assumed.<br/> public MailboxCountAction(string mailbox)
/// This property is mandatory. {
/// </summary> Mailbox = mailbox;
public string Mailbox }
{
get { return this.mailbox; } /// <summary>
set { this.mailbox = value; } /// Get the name of this action, i.e. "MailboxCount".
} /// </summary>
public override string Action
/// <summary> {
/// Creates a new empty MailboxCountAction. get { return "MailboxCount"; }
/// </summary> }
public MailboxCountAction()
{ /// <summary>
} /// Get/Set the name of the mailbox to query.<br />
/// This can either be only the number of the mailbox or a string of the form
/// <summary> /// mailboxnumber@context.If no context is specified "default" is assumed.<br />
/// Creates a new MailboxCountAction that queries the number of unread and /// This property is mandatory.
/// read messages in the given mailbox. /// </summary>
/// </summary> public string Mailbox { get; set; }
/// <param name="mailbox">the name of the mailbox to query.<br/> }
/// This can either be only the number of the mailbox or a string
/// of the form mailboxnumber@context.If no context is specified
/// "default" is assumed.
/// </param>
public MailboxCountAction(string mailbox)
{
this.mailbox = mailbox;
}
}
} }

View file

@ -1,57 +1,51 @@
using System;
namespace AsterNET.Manager.Action namespace AsterNET.Manager.Action
{ {
/// <summary> /// <summary>
/// The MailboxStatusAction checks if a mailbox contains waiting messages.<br/> /// The MailboxStatusAction checks if a mailbox contains waiting messages.<br />
/// The MailboxStatusAction returns a MailboxStatusResponse. /// The MailboxStatusAction returns a MailboxStatusResponse.
/// </summary> /// </summary>
/// <seealso cref="Manager.Response.MailboxStatusResponse" /> /// <seealso cref="Manager.Response.MailboxStatusResponse" />
public class MailboxStatusAction : ManagerAction public class MailboxStatusAction : ManagerAction
{ {
private string mailbox; /// <summary>
/// Creates a new empty MailboxStatusAction.
/// </summary>
public MailboxStatusAction()
{
}
/// <summary> /// <summary>
/// Get the name of this action, i.e. "MailboxStatus". /// Creates a new MailboxStatusAction that checks for waiting messages in the given mailbox.
/// </summary> /// </summary>
override public string Action /// <param name="mailbox">
{ /// the name of the mailbox to check.<br />
get { return "MailboxStatus"; } /// This can either be only the number of the mailbox or a string
} /// of the form mailboxnumber@context.If no context is specified
/// <summary> /// "default" is assumed.
/// Get/Set the name of the mailbox to query.<br/> /// </param>
/// This can either be only the name of the mailbox or a string of the form public MailboxStatusAction(string mailbox)
/// mailboxnumber@context. If no context is specified "default" is assumed.<br/> {
/// Multiple mailboxes may be given, separated by ','. In this case the Mailbox = mailbox;
/// action checks whether at least one of the given mailboxes has waiting }
/// messages.<br/>
/// This property is mandatory.<br/> /// <summary>
/// Example: "1234,1235@mycontext" /// Get the name of this action, i.e. "MailboxStatus".
/// </summary> /// </summary>
public string Mailbox public override string Action
{ {
get { return this.mailbox; } get { return "MailboxStatus"; }
set { this.mailbox = value; } }
}
/// <summary>
/// <summary> /// Get/Set the name of the mailbox to query.<br />
/// Creates a new empty MailboxStatusAction. /// This can either be only the name of the mailbox or a string of the form
/// </summary> /// mailboxnumber@context. If no context is specified "default" is assumed.<br />
public MailboxStatusAction() /// Multiple mailboxes may be given, separated by ','. In this case the
{ /// action checks whether at least one of the given mailboxes has waiting
} /// messages.<br />
/// This property is mandatory.<br />
/// <summary> /// Example: "1234,1235@mycontext"
/// Creates a new MailboxStatusAction that checks for waiting messages in the given mailbox. /// </summary>
/// </summary> public string Mailbox { get; set; }
/// <param name="mailbox">the name of the mailbox to check.<br/> }
/// This can either be only the number of the mailbox or a string
/// of the form mailboxnumber@context.If no context is specified
/// "default" is assumed.
/// </param>
public MailboxStatusAction(string mailbox)
{
this.mailbox = mailbox;
}
}
} }

View file

@ -1,66 +1,66 @@
using System.Text;
using System.Collections.Generic;
namespace AsterNET.Manager.Action namespace AsterNET.Manager.Action
{ {
/// <summary> /// <summary>
/// This class implements the ManagerAction interface /// This class implements the ManagerAction interface
/// and can serve as base class for your concrete Action implementations. /// and can serve as base class for your concrete Action implementations.
/// </summary> /// </summary>
public abstract class ManagerAction public abstract class ManagerAction
{ {
private string actionId; private string actionId;
private string server; private string proxyKey;
private string proxyKey; private string server;
/// <summary> /// <summary>
/// Manager API Action key. Also use as ProxyAction key to <see cref="ProxyAction">ProxyAction</see> actions. /// Manager API Action key. Also use as ProxyAction key to <see cref="ProxyAction">ProxyAction</see> actions.
/// </summary> /// </summary>
public abstract string Action public abstract string Action { get; }
{
get;
}
#region ActionId #region ActionId
public string ActionId
{
get { return this.actionId; }
set { this.actionId = value; }
}
#endregion
#region Server public string ActionId
/// <summary> {
/// Specify a server to which to send your commands (x.x.x.x or hostname).<br/> get { return this.actionId; }
/// This should match the server name specified in your config file's "host" entry. set { this.actionId = value; }
/// If you do not specify a server, the proxy will pick the first one it finds -- fine in single-server configurations. }
/// </summary>
public string Server
{
get { return this.server; }
set { this.server = value; }
}
#endregion
#region ProxyKey #endregion
/// <summary>
/// You can use this as a simple authentication mechanism.<br/>
/// Rather than have to login with a username & password,
/// you can specify a <b>ProxyKey</b> that must be passed from
/// a client before requests are processed.<br/>
/// This is helpful in situations where you would like to authenticate and
/// execute an action in a single step.
/// </summary>
public virtual string ProxyKey
{
get { return this.proxyKey; }
set { this.proxyKey = value; }
}
#endregion
public override string ToString() #region Server
{
return Helper.ToString(this); /// <summary>
} /// Specify a server to which to send your commands (x.x.x.x or hostname).<br />
} /// This should match the server name specified in your config file's "host" entry.
} /// If you do not specify a server, the proxy will pick the first one it finds -- fine in single-server configurations.
/// </summary>
public string Server
{
get { return this.server; }
set { this.server = value; }
}
#endregion
#region ProxyKey
/// <summary>
/// You can use this as a simple authentication mechanism.<br />
/// Rather than have to login with a username & password,
/// you can specify a <b>ProxyKey</b> that must be passed from
/// a client before requests are processed.<br />
/// This is helpful in situations where you would like to authenticate and
/// execute an action in a single step.
/// </summary>
public virtual string ProxyKey
{
get { return this.proxyKey; }
set { this.proxyKey = value; }
}
#endregion
public override string ToString()
{
return Helper.ToString(this);
}
}
}

View file

@ -2,19 +2,19 @@ using System;
namespace AsterNET.Manager.Action namespace AsterNET.Manager.Action
{ {
/// <summary> /// <summary>
/// The ManagerActionEvent is implemented by ManagerActions that /// The ManagerActionEvent is implemented by ManagerActions that
/// return their result not in a ManagerResponse but by sending a series of events.<br/> /// return their result not in a ManagerResponse but by sending a series of events.<br />
/// The event type that indicates that Asterisk is finished is returned by the /// The event type that indicates that Asterisk is finished is returned by the
/// ActionCompleteEventClass property. /// ActionCompleteEventClass property.
/// </summary> /// </summary>
/// <seealso cref="AsterNET.Manager.Event.ResponseEvent"/> /// <seealso cref="AsterNET.Manager.Event.ResponseEvent" />
public abstract class ManagerActionEvent : ManagerAction public abstract class ManagerActionEvent : ManagerAction
{ {
/// <summary> /// <summary>
/// Returns the event type that indicates that Asterisk is finished sending response events for this action. /// Returns the event type that indicates that Asterisk is finished sending response events for this action.
/// </summary> /// </summary>
/// <seealso cref="AsterNET.Manager.Event.ResponseEvent"/> /// <seealso cref="AsterNET.Manager.Event.ResponseEvent" />
public abstract Type ActionCompleteEventClass(); public abstract Type ActionCompleteEventClass();
} }
} }

View file

@ -1,21 +1,18 @@
using System;
using AsterNET.Manager.Response;
namespace AsterNET.Manager.Action namespace AsterNET.Manager.Action
{ {
/// <summary> /// <summary>
/// The ManagerActionResponse is implemented by ManagerActions that /// The ManagerActionResponse is implemented by ManagerActions that
/// return their result in a custom ManagerResponse<br/> /// return their result in a custom ManagerResponse<br />
/// The response type that indicates that Asterisk is finished is returned by the /// The response type that indicates that Asterisk is finished is returned by the
/// ActionCompleteResponseClass property. /// ActionCompleteResponseClass property.
/// </summary> /// </summary>
/// <seealso cref="AsterNET.Manager.Event.ResponseEvent"/> /// <seealso cref="AsterNET.Manager.Event.ResponseEvent" />
public abstract class ManagerActionResponse : ManagerAction public abstract class ManagerActionResponse : ManagerAction
{ {
/// <summary> /// <summary>
/// Returns the response type that indicates that Asterisk is finished sending response for this action. /// Returns the response type that indicates that Asterisk is finished sending response for this action.
/// </summary> /// </summary>
/// <seealso cref="AsterNET.Manager.Response"/> /// <seealso cref="AsterNET.Manager.Response" />
public abstract object ActionCompleteResponseClass(); public abstract object ActionCompleteResponseClass();
} }
} }

View file

@ -1,130 +1,125 @@
using System;
namespace AsterNET.Manager.Action namespace AsterNET.Manager.Action
{ {
/// <summary> /// <summary>
/// The MonitorAction starts monitoring (recording) a channel.<br/> /// The MonitorAction starts monitoring (recording) a channel.<br />
/// It is implemented in <code>res/res_monitor.c</code> /// It is implemented in <code>res/res_monitor.c</code>
/// </summary> /// </summary>
public class MonitorAction : ManagerAction public class MonitorAction : ManagerAction
{ {
private string channel; #region Action
private string file;
private string format;
private bool mix;
#region Action /// <summary>
/// <summary> /// Get the name of this action, i.e. "Monitor".
/// Get the name of this action, i.e. "Monitor". /// </summary>
/// </summary> public override string Action
override public string Action {
{ get { return "Monitor"; }
get { return "Monitor"; } }
}
#endregion
#region Channel #endregion
/// <summary>
/// Get/Set the name of the channel to monitor.<br/>
/// This property is mandatory.
/// </summary>
public string Channel
{
get { return this.channel; }
set { this.channel = value; }
}
#endregion
#region File #region Channel
/// <summary>
/// Get/Set the name of the file to which the voice data is written.<br/>
/// If this property is not set it defaults to to the channel name as per CLI with the '/' replaced by '-'.
/// </summary>
public string File
{
get { return this.file; }
set { this.file = value; }
}
#endregion
#region Format /// <summary>
/// <summary> /// Get/Set the name of the channel to monitor.<br />
/// Get/Set the format to use for encoding the voice files.<br/> /// This property is mandatory.
/// If this property is not set it defaults to "wav". /// </summary>
/// </summary> public string Channel { get; set; }
public string Format
{
get { return this.format; }
set { this.format = value; }
}
#endregion
#region Mix #endregion
/// <summary>
/// Returns true if the two voice files should be joined at the end of the call.
/// </summary>
public bool Mix
{
get { return this.mix; }
set { this.mix = value; }
}
#endregion
#region MonitorAction() #region File
/// <summary>
/// Creates a new empty MonitorAction.
/// </summary>
public MonitorAction()
{
}
#endregion
#region MonitorAction(string channel, string file) /// <summary>
/// <summary> /// Get/Set the name of the file to which the voice data is written.<br />
/// Creates a new MonitorAction that starts monitoring the given channel and /// If this property is not set it defaults to to the channel name as per CLI with the '/' replaced by '-'.
/// writes voice data to the given file(s). /// </summary>
/// </summary> public string File { get; set; }
/// <param name="channel">the name of the channel to monitor</param>
/// <param name="file">the (base) name of the file(s) to which the voice data is written</param>
public MonitorAction(string channel, string file)
{
this.channel = channel;
this.file = file;
}
#endregion
#region MonitorAction(string channel, string file) #endregion
/// <summary>
/// Creates a new MonitorAction that starts monitoring the given channel and
/// writes voice data to the given file(s).
/// </summary>
/// <param name="channel">the name of the channel to monitor</param>
/// <param name="file">the (base) name of the file(s) to which the voice data is written</param>
/// <param name="format">the format to use for encoding the voice files</param>
public MonitorAction(string channel, string file, string format)
{
this.channel = channel;
this.file = file;
this.format = format;
}
#endregion
#region MonitorAction(string channel, string file, string format, int mix) #region Format
/// <summary>
/// Creates a new MonitorAction that starts monitoring the given channel and /// <summary>
/// writes voice data to the given file(s). /// Get/Set the format to use for encoding the voice files.<br />
/// </summary> /// If this property is not set it defaults to "wav".
/// <param name="channel">the name of the channel to monitor</param> /// </summary>
/// <param name="file">the (base) name of the file(s) to which the voice data is written</param> public string Format { get; set; }
/// <param name="format">the format to use for encoding the voice files</param>
/// <param name="mix">true if the two voice files should be joined at the end of the call</param> #endregion
public MonitorAction(string channel, string file, string format, bool mix)
{ #region Mix
this.channel = channel;
this.file = file; /// <summary>
this.format = format; /// Returns true if the two voice files should be joined at the end of the call.
this.mix = mix; /// </summary>
} public bool Mix { get; set; }
#endregion
} #endregion
#region MonitorAction()
/// <summary>
/// Creates a new empty MonitorAction.
/// </summary>
public MonitorAction()
{
}
#endregion
#region MonitorAction(string channel, string file)
/// <summary>
/// Creates a new MonitorAction that starts monitoring the given channel and
/// writes voice data to the given file(s).
/// </summary>
/// <param name="channel">the name of the channel to monitor</param>
/// <param name="file">the (base) name of the file(s) to which the voice data is written</param>
public MonitorAction(string channel, string file)
{
Channel = channel;
File = file;
}
#endregion
#region MonitorAction(string channel, string file)
/// <summary>
/// Creates a new MonitorAction that starts monitoring the given channel and
/// writes voice data to the given file(s).
/// </summary>
/// <param name="channel">the name of the channel to monitor</param>
/// <param name="file">the (base) name of the file(s) to which the voice data is written</param>
/// <param name="format">the format to use for encoding the voice files</param>
public MonitorAction(string channel, string file, string format)
{
Channel = channel;
File = file;
Format = format;
}
#endregion
#region MonitorAction(string channel, string file, string format, int mix)
/// <summary>
/// Creates a new MonitorAction that starts monitoring the given channel and
/// writes voice data to the given file(s).
/// </summary>
/// <param name="channel">the name of the channel to monitor</param>
/// <param name="file">the (base) name of the file(s) to which the voice data is written</param>
/// <param name="format">the format to use for encoding the voice files</param>
/// <param name="mix">true if the two voice files should be joined at the end of the call</param>
public MonitorAction(string channel, string file, string format, bool mix)
{
Channel = channel;
File = file;
Format = format;
Mix = mix;
}
#endregion
}
} }

View file

@ -1,239 +1,224 @@
using System; using System;
using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using AsterNET.Manager.Event;
namespace AsterNET.Manager.Action namespace AsterNET.Manager.Action
{ {
/// <summary> /// <summary>
/// The OriginateAction generates an outgoing call to the extension in the given /// The OriginateAction generates an outgoing call to the extension in the given
/// context with the given priority or to a given application with optional /// context with the given priority or to a given application with optional
/// parameters.<br/> /// parameters.<br />
/// If you want to connect to an extension use the properties context, exten and /// If you want to connect to an extension use the properties context, exten and
/// priority. If you want to connect to an application use the properties /// priority. If you want to connect to an application use the properties
/// application and data if needed. Note that no call detail record will be /// application and data if needed. Note that no call detail record will be
/// written when directly connecting to an application, so it may be better to /// written when directly connecting to an application, so it may be better to
/// connect to an extension that starts the application you wish to connect to.<br/> /// connect to an extension that starts the application you wish to connect to.<br />
/// The response to this action is sent when the channel has been answered and /// The response to this action is sent when the channel has been answered and
/// asterisk starts connecting it to the given extension. So be careful not to /// asterisk starts connecting it to the given extension. So be careful not to
/// choose a too short timeout when waiting for the response.<br/> /// choose a too short timeout when waiting for the response.<br />
/// If you set async to <code>true</code> Asterisk reports an OriginateSuccess- /// If you set async to <code>true</code> Asterisk reports an OriginateSuccess-
/// and OriginateFailureEvents. The action id of these events equals the action /// and OriginateFailureEvents. The action id of these events equals the action
/// id of this OriginateAction. /// id of this OriginateAction.
/// </summary> /// </summary>
/// <seealso cref="AsterNET.Manager.Event.OriginateSuccessEvent" /> /// <seealso cref="AsterNET.Manager.Event.OriginateSuccessEvent" />
/// <seealso cref="AsterNET.Manager.Event.OriginateFailureEvent" /> /// <seealso cref="AsterNET.Manager.Event.OriginateFailureEvent" />
public class OriginateAction : ManagerActionEvent public class OriginateAction : ManagerActionEvent
{ {
private string channel; private Dictionary<string, string> variables;
private string exten;
private string context;
private string priority;
private int timeout;
private string callerId;
private Dictionary<string, string> variables;
private string account;
private string application;
private string data;
private bool async;
#region Action #region Action
/// <summary>
/// Get the name of this action, i.e. "Originate".
/// </summary>
override public string Action
{
get { return "Originate"; }
}
#endregion
#region Account /// <summary>
/// <summary> /// Get the name of this action, i.e. "Originate".
/// Get/Set the account code to use for the originated call. /// </summary>
/// The account code is included in the call detail record generated for this call and will be used for billing. public override string Action
/// </summary> {
public string Account get { return "Originate"; }
{ }
get { return account; }
set { this.account = value; }
}
#endregion
#region CallerId #endregion
/// <summary>
/// Get/Set the caller id to set on the outgoing channel.
/// </summary>
public string CallerId
{
get { return callerId; }
set { this.callerId = value; }
}
#endregion
#region Channel #region Account
/// <summary>
/// Get/Set Channel on which to originate the call (The same as you specify in the Dial application command)<br/>
/// This property is required.
/// </summary>
public string Channel
{
get { return channel; }
set { this.channel = value; }
}
#endregion
#region Context /// <summary>
/// <summary> /// Get/Set the account code to use for the originated call.
/// Get/Set the name of the context of the extension to connect to. /// The account code is included in the call detail record generated for this call and will be used for billing.
/// If you set the context you also have to set the exten and priority properties. /// </summary>
/// </summary> public string Account { get; set; }
public string Context
{
get { return context; }
set { this.context = value; }
}
#endregion
#region Exten #endregion
/// <summary>
/// Get/Ser the extension to connect to.
/// If you set the extension you also have to set the context and priority properties.
/// </summary>
public string Exten
{
get { return exten; }
set { this.exten = value; }
}
#endregion
#region Priority #region CallerId
/// <summary>
/// Get /Set the priority of the extension to connect to.
/// If you set the priority you also have to set the context and exten properties.
/// </summary>
public string Priority
{
get { return priority; }
set { this.priority = value; }
}
#endregion
#region Application /// <summary>
/// <summary> /// Get/Set the caller id to set on the outgoing channel.
/// Get/Set Application to use on connect (use Data for parameters) /// </summary>
/// </summary> public string CallerId { get; set; }
public string Application
{
get { return application; }
set { this.application = value; }
}
#endregion
#region Data #endregion
/// <summary>
/// Get/Set the parameters to pass to the application.
/// Data if Application parameter is user
/// </summary>
/// <summary> Sets the parameters to pass to the application.</summary>
public string Data
{
get { return data; }
set { this.data = value; }
}
#endregion
#region Async #region Channel
/// <summary>
/// Get/Set <code>true</code> if this is a fast origination.<br/>
/// For the origination to be asynchronous (allows multiple calls to be generated without waiting for a response).<br/>
/// Will send OriginateSuccess- and OriginateFailureEvents.
/// </summary>
public bool Async
{
get { return async; }
set { this.async = value; }
}
#endregion
#region ActionCompleteEventClass /// <summary>
public override Type ActionCompleteEventClass() /// Get/Set Channel on which to originate the call (The same as you specify in the Dial application command)<br />
{ /// This property is required.
return typeof(Event.OriginateResponseEvent); /// </summary>
} public string Channel { get; set; }
#endregion
#region Timeout #endregion
/// <summary>
/// Get/Set the timeout for the origination in seconds.<br/>
/// The channel must be answered within this time, otherwise the origination
/// is considered to have failed and an OriginateFailureEvent is generated.<br/>
/// If not set, Asterisk assumes a default value of 30000 meaning 30 seconds.
/// </summary>
public int Timeout
{
get { return timeout; }
set { this.timeout = value; }
}
#endregion
#region Variable #region Context
/// <summary>
/// Get/Set the variables to set on the originated call.<br/>
/// Variable assignments are of the form "VARNAME=VALUE". You can specify
/// multiple variable assignments separated by the '|' character.<br/>
/// Example: "VAR1=abc|VAR2=def" sets the channel variables VAR1 to "abc" and VAR2 to "def".
/// </summary>
public string Variable
{
get { return Helper.JoinVariables(variables, Common.VAR_DELIMITER, "="); }
set { variables = Helper.ParseVariables(variables, value, Common.VAR_DELIMITER); }
}
#endregion
#region GetVariables() /// <summary>
/// <summary> /// Get/Set the name of the context of the extension to connect to.
/// Get the variables dictionary to set on the originated call. /// If you set the context you also have to set the exten and priority properties.
/// </summary> /// </summary>
public Dictionary<string, string> GetVariables() public string Context { get; set; }
{
return variables;
}
#endregion
#region SetVariables(IDictionary vars) #endregion
/// <summary>
/// Set the variables dictionary to set on the originated call.
/// </summary>
public void SetVariables(Dictionary<string, string> vars)
{
this.variables = vars;
}
#endregion
#region GetVariable(string name, string val) #region Exten
/// <summary>
/// Gets a variable on the originated call. Replaces any existing variable with the same name.
/// </summary>
public string GetVariable(string key)
{
if (variables == null)
return string.Empty;
return variables[key];
}
#endregion
#region SetVariable(string name, string val) /// <summary>
/// <summary> /// Get/Ser the extension to connect to.
/// Sets a variable dictionary on the originated call. Replaces any existing variable with the same name. /// If you set the extension you also have to set the context and priority properties.
/// </summary> /// </summary>
public void SetVariable(string key, string value) public string Exten { get; set; }
{
if (variables == null) #endregion
variables = new Dictionary<string, string>();
if (variables.ContainsKey(key)) #region Priority
variables[key] = value;
else /// <summary>
variables.Add(key, value); /// Get /Set the priority of the extension to connect to.
} /// If you set the priority you also have to set the context and exten properties.
#endregion /// </summary>
} public string Priority { get; set; }
#endregion
#region Application
/// <summary>
/// Get/Set Application to use on connect (use Data for parameters)
/// </summary>
public string Application { get; set; }
#endregion
#region Data
/// <summary>
/// Get/Set the parameters to pass to the application.
/// Data if Application parameter is user
/// </summary>
/// <summary> Sets the parameters to pass to the application.</summary>
public string Data { get; set; }
#endregion
#region Async
/// <summary>
/// Get/Set <code>true</code> if this is a fast origination.<br />
/// For the origination to be asynchronous (allows multiple calls to be generated without waiting for a response).
/// <br />
/// Will send OriginateSuccess- and OriginateFailureEvents.
/// </summary>
public bool Async { get; set; }
#endregion
#region ActionCompleteEventClass
public override Type ActionCompleteEventClass()
{
return typeof (OriginateResponseEvent);
}
#endregion
#region Timeout
/// <summary>
/// Get/Set the timeout for the origination in seconds.<br />
/// The channel must be answered within this time, otherwise the origination
/// is considered to have failed and an OriginateFailureEvent is generated.<br />
/// If not set, Asterisk assumes a default value of 30000 meaning 30 seconds.
/// </summary>
public int Timeout { get; set; }
#endregion
#region Variable
/// <summary>
/// Get/Set the variables to set on the originated call.<br />
/// Variable assignments are of the form "VARNAME=VALUE". You can specify
/// multiple variable assignments separated by the '|' character.<br />
/// Example: "VAR1=abc|VAR2=def" sets the channel variables VAR1 to "abc" and VAR2 to "def".
/// </summary>
public string Variable
{
get { return Helper.JoinVariables(variables, Common.VAR_DELIMITER, "="); }
set { variables = Helper.ParseVariables(variables, value, Common.VAR_DELIMITER); }
}
#endregion
#region GetVariables()
/// <summary>
/// Get the variables dictionary to set on the originated call.
/// </summary>
public Dictionary<string, string> GetVariables()
{
return variables;
}
#endregion
#region SetVariables(IDictionary vars)
/// <summary>
/// Set the variables dictionary to set on the originated call.
/// </summary>
public void SetVariables(Dictionary<string, string> vars)
{
variables = vars;
}
#endregion
#region GetVariable(string name, string val)
/// <summary>
/// Gets a variable on the originated call. Replaces any existing variable with the same name.
/// </summary>
public string GetVariable(string key)
{
if (variables == null)
return string.Empty;
return variables[key];
}
#endregion
#region SetVariable(string name, string val)
/// <summary>
/// Sets a variable dictionary on the originated call. Replaces any existing variable with the same name.
/// </summary>
public void SetVariable(string key, string value)
{
if (variables == null)
variables = new Dictionary<string, string>();
if (variables.ContainsKey(key))
variables[key] = value;
else
variables.Add(key, value);
}
#endregion
}
} }

View file

@ -1,75 +1,26 @@
using System; namespace AsterNET.Manager.Action
namespace AsterNET.Manager.Action
{ {
/// <summary> /// <summary>
/// The ParkAction allows to send a Channel to a Parking lot.<br/> /// The ParkAction allows to send a Channel to a Parking lot.<br />
/// A successful login is the precondition for sending for that /// A successful login is the precondition for sending for that
/// </summary> /// </summary>
public class ParkAction : ManagerAction public class ParkAction : ManagerAction
{ {
private string channel;
private string channel2;
private string timeout;
private string parkinglot;
/// <summary> /// <summary>
/// Get the name of this action, i.e. "Park". /// Creates a new ParkAction.
/// </summary>
override public string Action
{
get { return "Park"; }
}
/// <summary>
/// Set the Channel which should be parked
/// </summary>
public string Channel
{
get { return this.channel; }
set { this.channel = value; }
}
/// <summary>
/// Set the Channel where the Call will end up after the timeout is reached.
/// </summary>
public string Channel2
{
get { return this.channel2; }
set { this.channel2 = value; }
}
/// <summary>
/// Timeout in msec, after timeout is reached call will come back to channel2
/// </summary>
public string Timeout
{
get { return this.timeout; }
set { this.timeout = value; }
}
/// <summary>
/// Set the Parking lot.
/// </summary>
public string Parkinglot
{
get { return this.parkinglot; }
set { this.parkinglot = value; }
}
/// <summary>
/// Creates a new ParkAction.
/// </summary> /// </summary>
/// <param name="channel"></param> /// <param name="channel"></param>
/// <param name="channel2"></param> /// <param name="channel2"></param>
/// <param name="timeout"></param> /// <param name="timeout"></param>
public ParkAction(string channel, string channel2, string timeout) public ParkAction(string channel, string channel2, string timeout)
{ {
this.channel = channel; this.Channel = channel;
this.channel2 = channel2; this.Channel2 = channel2;
this.timeout = timeout; this.Timeout = timeout;
} }
/// <summary> /// <summary>
/// Creates a new ParkAction.<br/> /// Creates a new ParkAction.<br />
/// </summary> /// </summary>
/// <param name="channel">Set the Channel which should be parked</param> /// <param name="channel">Set the Channel which should be parked</param>
/// <param name="channel2">Set the Channel where the Call will end up after the timeout is reached.</param> /// <param name="channel2">Set the Channel where the Call will end up after the timeout is reached.</param>
@ -77,10 +28,38 @@ namespace AsterNET.Manager.Action
/// <param name="parkinglot">Set the Parking lot.</param> /// <param name="parkinglot">Set the Parking lot.</param>
public ParkAction(string channel, string channel2, string timeout, string parkinglot) public ParkAction(string channel, string channel2, string timeout, string parkinglot)
{ {
this.channel = channel; this.Channel = channel;
this.channel2 = channel2; this.Channel2 = channel2;
this.timeout = timeout; this.Timeout = timeout;
this.parkinglot = parkinglot; this.Parkinglot = parkinglot;
} }
/// <summary>
/// Get the name of this action, i.e. "Park".
/// </summary>
public override string Action
{
get { return "Park"; }
}
/// <summary>
/// Set the Channel which should be parked
/// </summary>
public string Channel { get; set; }
/// <summary>
/// Set the Channel where the Call will end up after the timeout is reached.
/// </summary>
public string Channel2 { get; set; }
/// <summary>
/// Timeout in msec, after timeout is reached call will come back to channel2
/// </summary>
public string Timeout { get; set; }
/// <summary>
/// Set the Parking lot.
/// </summary>
public string Parkinglot { get; set; }
} }
} }

View file

@ -1,32 +1,26 @@
using System; using System;
using AsterNET.Manager.Event;
namespace AsterNET.Manager.Action namespace AsterNET.Manager.Action
{ {
/// <summary> /// <summary>
/// The ParkedCallsAction requests a list of all currently parked calls.<br/> /// The ParkedCallsAction requests a list of all currently parked calls.<br />
/// For each active channel a ParkedCallEvent is generated. After all parked /// For each active channel a ParkedCallEvent is generated. After all parked
/// calls have been reported a ParkedCallsCompleteEvent is generated. /// calls have been reported a ParkedCallsCompleteEvent is generated.
/// </summary> /// </summary>
/// <seealso cref="AsterNET.Manager.Event.ParkedCallEvent"/> /// <seealso cref="AsterNET.Manager.Event.ParkedCallEvent" />
/// <seealso cref="AsterNET.Manager.Event.ParkedCallsCompleteEvent"/> /// <seealso cref="AsterNET.Manager.Event.ParkedCallsCompleteEvent" />
public class ParkedCallsAction : ManagerActionEvent public class ParkedCallsAction : ManagerActionEvent
{ {
/// <summary> Get the name of this action, i.e. "ParkedCalls".</summary> /// <summary> Get the name of this action, i.e. "ParkedCalls".</summary>
public override string Action public override string Action
{ {
get { return "ParkedCalls"; } get { return "ParkedCalls"; }
} }
public override Type ActionCompleteEventClass() public override Type ActionCompleteEventClass()
{ {
return typeof(Event.ParkedCallsCompleteEvent); return typeof (ParkedCallsCompleteEvent);
} }
}
/// <summary>
/// Creates a new ParkedCallsAction.
/// </summary>
public ParkedCallsAction()
{
}
}
} }

View file

@ -1,26 +1,17 @@
using System;
namespace AsterNET.Manager.Action namespace AsterNET.Manager.Action
{ {
/// <summary> /// <summary>
/// The PingAction will ellicit a 'Pong' response, it is used to keep the manager /// The PingAction will ellicit a 'Pong' response, it is used to keep the manager
/// connection open and performs no operation. /// connection open and performs no operation.
/// </summary> /// </summary>
public class PingAction : ManagerAction public class PingAction : ManagerAction
{ {
/// <summary> /// <summary>
/// Get the name of this action, i.e. "Ping". /// Get the name of this action, i.e. "Ping".
/// </summary> /// </summary>
override public string Action public override string Action
{ {
get { return "Ping"; } get { return "Ping"; }
} }
}
/// <summary>
/// Creates a new PingAction.
/// </summary>
public PingAction()
{
}
}
} }

View file

@ -1,10 +1,6 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace AsterNET.Manager.Action namespace AsterNET.Manager.Action
{ {
public abstract class ProxyAction : ManagerAction public abstract class ProxyAction : ManagerAction
{ {
} }
} }

View file

@ -1,120 +1,98 @@
using System;
namespace AsterNET.Manager.Action namespace AsterNET.Manager.Action
{ {
/// <summary> /// <summary>
/// The QueueAddAction adds a new member to a queue.<br/> /// The QueueAddAction adds a new member to a queue.<br />
/// It is implemented in <code>apps/app_queue.c</code> /// It is implemented in <code>apps/app_queue.c</code>
/// </summary> /// </summary>
public class QueueAddAction : ManagerAction public class QueueAddAction : ManagerAction
{ {
private string queue; /// <summary>
private string iface; /// Creates a new empty QueueAddAction.
private string memberName; /// </summary>
private int penalty; public QueueAddAction()
private bool paused; {
}
/// <summary> /// <summary>
/// Get the name of this action, i.e. "QueueAdd". /// Creates a new QueueAddAction that adds a new member on the given interface to the given queue.
/// </summary> /// </summary>
override public string Action /// <param name="queue">the name of the queue the new member will be added to</param>
{ /// <param name="iface">Sets the interface to add. To add a specific channel just use the channel name, e.g. "SIP/1234".</param>
get { return "QueueAdd"; } public QueueAddAction(string queue, string iface)
} {
/// <summary> this.Queue = queue;
/// Get/Set the name of the queue the new member will be added to.<br/> this.Interface = iface;
/// This property is mandatory. }
/// </summary>
public string Queue
{
get { return this.queue; }
set { this.queue = value; }
}
/// <summary>
/// Get/Set the interface to add. To add a specific channel just use the channel name, e.g. "SIP/1234".<br/>
/// This property is mandatory.
/// </summary>
public string Interface
{
get { return this.iface; }
set { this.iface = value; }
}
/// <summary>
/// Get/Set the member to add.
/// </summary>
public string MemberName
{
get { return this.memberName; }
set { this.memberName = value; }
}
/// <summary>
/// Get/Set the penalty for this member.<br/>
/// The penalty must be a positive integer or 0 for no penalty. If it is not set 0 is assumed.<br/>
/// When calls are distributed members with higher penalties are considered last.
/// </summary>
public int Penalty
{
get { return this.penalty; }
set { this.penalty = value; }
}
/// <summary>
/// Get/Set if the queue member should be paused when added.<br/>
/// <code>true</code> if the queue member should be paused when added.
/// </summary>
public bool Paused
{
get { return this.paused; }
set { this.paused = value; }
}
/// <summary>
/// Creates a new empty QueueAddAction.
/// </summary>
public QueueAddAction()
{
}
/// <summary>
/// Creates a new QueueAddAction that adds a new member on the given interface to the given queue.
/// </summary>
/// <param name="queue">the name of the queue the new member will be added to</param>
/// <param name="iface">Sets the interface to add. To add a specific channel just use the channel name, e.g. "SIP/1234".</param>
public QueueAddAction(string queue, string iface)
{
this.queue = queue;
this.iface = iface;
}
/// <summary>
/// Creates a new QueueAddAction that adds a new member on the given interface to the given queue.
/// </summary>
/// <param name="queue">the name of the queue the new member will be added to</param>
/// <param name="iface">Sets the interface to add. To add a specific channel just use the channel name, e.g. "SIP/1234".</param>
/// <param name="memberName">the name of the the new member will be added to</param>
public QueueAddAction(string queue, string iface, string memberName)
{
this.queue = queue;
this.iface = iface;
this.memberName = memberName;
}
/// <summary> /// <summary>
/// Creates a new QueueAddAction that adds a new member on the given /// Creates a new QueueAddAction that adds a new member on the given interface to the given queue.
/// interface to the given queue with the given penalty. /// </summary>
/// </summary> /// <param name="queue">the name of the queue the new member will be added to</param>
/// <param name="queue">the name of the queue the new member will be added to</param> /// <param name="iface">Sets the interface to add. To add a specific channel just use the channel name, e.g. "SIP/1234".</param>
/// <param name="iface">Sets the interface to add. To add a specific channel just use the channel name, e.g. "SIP/1234".</param> /// <param name="memberName">the name of the the new member will be added to</param>
/// <param name="memberName">the name of the the new member will be added to</param> public QueueAddAction(string queue, string iface, string memberName)
/// <param name="penalty">the penalty for this member.<br/> {
/// The penalty must be a positive integer or 0 for no penalty. When calls are this.Queue = queue;
/// distributed members with higher penalties are considered last. this.Interface = iface;
/// </param> this.MemberName = memberName;
public QueueAddAction(string queue, string iface, string memberName, int penalty) }
{
this.queue = queue; /// <summary>
this.iface = iface; /// Creates a new QueueAddAction that adds a new member on the given
this.memberName = memberName; /// interface to the given queue with the given penalty.
this.penalty = penalty; /// </summary>
} /// <param name="queue">the name of the queue the new member will be added to</param>
} /// <param name="iface">Sets the interface to add. To add a specific channel just use the channel name, e.g. "SIP/1234".</param>
/// <param name="memberName">the name of the the new member will be added to</param>
/// <param name="penalty">
/// the penalty for this member.<br />
/// The penalty must be a positive integer or 0 for no penalty. When calls are
/// distributed members with higher penalties are considered last.
/// </param>
public QueueAddAction(string queue, string iface, string memberName, int penalty)
{
this.Queue = queue;
this.Interface = iface;
this.MemberName = memberName;
this.Penalty = penalty;
}
/// <summary>
/// Get the name of this action, i.e. "QueueAdd".
/// </summary>
public override string Action
{
get { return "QueueAdd"; }
}
/// <summary>
/// Get/Set the name of the queue the new member will be added to.<br />
/// This property is mandatory.
/// </summary>
public string Queue { get; set; }
/// <summary>
/// Get/Set the interface to add. To add a specific channel just use the channel name, e.g. "SIP/1234".<br />
/// This property is mandatory.
/// </summary>
public string Interface { get; set; }
/// <summary>
/// Get/Set the member to add.
/// </summary>
public string MemberName { get; set; }
/// <summary>
/// Get/Set the penalty for this member.<br />
/// The penalty must be a positive integer or 0 for no penalty. If it is not set 0 is assumed.<br />
/// When calls are distributed members with higher penalties are considered last.
/// </summary>
public int Penalty { get; set; }
/// <summary>
/// Get/Set if the queue member should be paused when added.<br />
/// <code>true</code> if the queue member should be paused when added.
/// </summary>
public bool Paused { get; set; }
}
} }

View file

@ -1,28 +1,16 @@
using System; namespace AsterNET.Manager.Action
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace AsterNET.Manager.Action
{ {
public class QueueLogAction : ManagerAction public class QueueLogAction : ManagerAction
{ {
private string _queue;
private string _event;
private string _uniqueid;
private string _interface;
private string _message;
/// <summary> /// <summary>
/// Adds custom entry in queue_log. /// Adds custom entry in queue_log.
/// </summary> /// </summary>
public QueueLogAction() public QueueLogAction()
{ {
} }
/// <summary> /// <summary>
/// Adds custom entry in queue_log. /// Adds custom entry in queue_log.
/// </summary> /// </summary>
/// <param name="queue"></param> /// <param name="queue"></param>
/// <param name="event"></param> /// <param name="event"></param>
@ -31,11 +19,11 @@ namespace AsterNET.Manager.Action
/// <param name="message"></param> /// <param name="message"></param>
public QueueLogAction(string queue, string @event, string uniqueid, string @interface, string message) public QueueLogAction(string queue, string @event, string uniqueid, string @interface, string message)
{ {
_queue = queue; Queue = queue;
_event = @event; Event = @event;
_uniqueid = uniqueid; Uniqueid = uniqueid;
_interface = @interface; Interface = @interface;
_message = message; Message = message;
} }
public override string Action public override string Action
@ -43,34 +31,14 @@ namespace AsterNET.Manager.Action
get { return "QueueLog"; } get { return "QueueLog"; }
} }
public string Queue public string Queue { get; set; }
{
get { return _queue; }
set { _queue = value; }
}
public string Event public string Event { get; set; }
{
get { return _event; }
set { _event = value; }
}
public string Uniqueid public string Uniqueid { get; set; }
{
get { return _uniqueid; }
set { _uniqueid = value; }
}
public string Interface public string Interface { get; set; }
{
get { return _interface; }
set { _interface = value; }
}
public string Message public string Message { get; set; }
{
get { return _message; }
set { _message = value; }
}
} }
} }

View file

@ -1,112 +1,93 @@
using System;
namespace AsterNET.Manager.Action namespace AsterNET.Manager.Action
{ {
/// <summary> /// <summary>
/// The QueuePauseAction makes a queue member temporarily unavailabe (or available again).<br/> /// The QueuePauseAction makes a queue member temporarily unavailabe (or available again).<br />
/// It is implemented in <code>apps/app_queue.c</code><br/> /// It is implemented in <code>apps/app_queue.c</code><br />
/// Available since Asterisk 1.2. /// Available since Asterisk 1.2.
/// </summary> /// </summary>
public class QueuePauseAction : ManagerAction public class QueuePauseAction : ManagerAction
{ {
private string iface; /// <summary>
private bool paused; /// Creates a new empty QueuePauseAction.
private string queue; /// </summary>
public QueuePauseAction()
{
}
/// <summary> /// <summary>
/// Get the name of this action, i.e. "QueuePause". /// Creates a new QueuePauseAction that makes the member on the given
/// </summary> /// interface unavailable on all queues.
override public string Action /// </summary>
{ /// <param name="iface">the interface of the member to make unavailable</param>
get public QueuePauseAction(string iface)
{ {
return "QueuePause"; this.Interface = iface;
} Paused = true;
}
}
/// <summary> /// <summary>
/// Get/Set the interface of the member to make available or unavailable.<br/> /// Creates a new QueuePauseAction that makes the member on the given
/// This property is mandatory. /// interface unavailable on the given queue.
/// </summary> /// </summary>
public string Interface /// <param name="iface">the interface of the member to make unavailable</param>
{ /// <param name="queue">the queue the member is made unvailable on</param>
get { return this.iface; } public QueuePauseAction(string iface, string queue)
set { this.iface = value; } {
} this.Interface = iface;
/// <summary> this.Queue = queue;
/// Get/Set Returns the name of the queue the member is made available or unavailable on. Paused = true;
/// </summary> }
public string Queue
{ /// <summary>
get { return this.queue; } /// Creates a new QueuePauseAction that makes the member on the given
set { this.queue = value; } /// interface available or unavailable on all queues.
} /// </summary>
/// <summary> /// <param name="iface">the interface of the member to make unavailable</param>
/// Get/Set if the member is made available or unavailable.<br/> /// <param name="paused"><code>true</code> to make the member unavailbale, <code>false</code> to make the member available</param>
/// <code>true</code> to make the member unavailbale,<br/> public QueuePauseAction(string iface, bool paused)
/// <code>false</code> make the member available {
/// </summary> this.Interface = iface;
public bool Paused this.Paused = paused;
{ }
get { return this.paused; }
set { this.paused = value; } /// <summary>
} /// Creates a new QueuePauseAction that makes the member on the given
/// interface unavailable on the given queue.
/// <summary> /// </summary>
/// Creates a new empty QueuePauseAction. /// <param name="iface">the interface of the member to make unavailable</param>
/// </summary> /// <param name="queue">the queue the member is made unvailable on</param>
public QueuePauseAction() /// <param name="paused"><code>true</code> to make the member unavailbale, <code>false</code> to make the member available</param>
{ public QueuePauseAction(string iface, string queue, bool paused)
} {
this.Interface = iface;
/// <summary> this.Queue = queue;
/// Creates a new QueuePauseAction that makes the member on the given this.Paused = paused;
/// interface unavailable on all queues. }
/// </summary>
/// <param name="iface">the interface of the member to make unavailable</param> /// <summary>
public QueuePauseAction(string iface) /// Get the name of this action, i.e. "QueuePause".
{ /// </summary>
this.iface = iface; public override string Action
this.paused = true; {
} get { return "QueuePause"; }
}
/// <summary>
/// Creates a new QueuePauseAction that makes the member on the given /// <summary>
/// interface unavailable on the given queue. /// Get/Set the interface of the member to make available or unavailable.<br />
/// </summary> /// This property is mandatory.
/// <param name="iface">the interface of the member to make unavailable</param> /// </summary>
/// <param name="queue">the queue the member is made unvailable on</param> public string Interface { get; set; }
public QueuePauseAction(string iface, string queue)
{ /// <summary>
this.iface = iface; /// Get/Set Returns the name of the queue the member is made available or unavailable on.
this.queue = queue; /// </summary>
this.paused = true; public string Queue { get; set; }
}
/// <summary>
/// <summary> /// Get/Set if the member is made available or unavailable.<br />
/// Creates a new QueuePauseAction that makes the member on the given /// <code>true</code> to make the member unavailbale,<br />
/// interface available or unavailable on all queues. /// <code>false</code> make the member available
/// </summary> /// </summary>
/// <param name="iface">the interface of the member to make unavailable</param> public bool Paused { get; set; }
/// <param name="paused"><code>true</code> to make the member unavailbale, <code>false</code> to make the member available</param> }
public QueuePauseAction(string iface, bool paused)
{
this.iface = iface;
this.paused = paused;
}
/// <summary>
/// Creates a new QueuePauseAction that makes the member on the given
/// interface unavailable on the given queue.
/// </summary>
/// <param name="iface">the interface of the member to make unavailable</param>
/// <param name="queue">the queue the member is made unvailable on</param>
/// <param name="paused"><code>true</code> to make the member unavailbale, <code>false</code> to make the member available</param>
public QueuePauseAction(string iface, string queue, bool paused)
{
this.iface = iface;
this.queue = queue;
this.paused = paused;
}
}
} }

View file

@ -1,35 +1,25 @@
using System; namespace AsterNET.Manager.Action
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace AsterNET.Manager.Action
{ {
public class QueuePenaltyAction : ManagerAction public class QueuePenaltyAction : ManagerAction
{ {
private string _interface;
private string _penalty;
private string _queue;
/// <summary> /// <summary>
/// Set the penalty for a queue member. /// Set the penalty for a queue member.
/// </summary> /// </summary>
public QueuePenaltyAction() public QueuePenaltyAction()
{ {
} }
/// <summary> /// <summary>
/// Set the penalty for a queue member. /// Set the penalty for a queue member.
/// </summary> /// </summary>
/// <param name="interface"></param> /// <param name="interface"></param>
/// <param name="penalty"></param> /// <param name="penalty"></param>
/// <param name="queue"></param> /// <param name="queue"></param>
public QueuePenaltyAction(string @interface, string penalty, string queue) public QueuePenaltyAction(string @interface, string penalty, string queue)
{ {
_interface = @interface; Interface = @interface;
_penalty = penalty; Penalty = penalty;
_queue = queue; Queue = queue;
} }
public override string Action public override string Action
@ -37,22 +27,10 @@ namespace AsterNET.Manager.Action
get { return "QueuePenalty"; } get { return "QueuePenalty"; }
} }
public string Interface public string Interface { get; set; }
{
get { return _interface; }
set { _interface = value; }
}
public string Penalty public string Penalty { get; set; }
{
get { return _penalty; }
set { _penalty = value; }
}
public string Queue public string Queue { get; set; }
{
get { return _queue; }
set { _queue = value; }
}
} }
} }

View file

@ -1,27 +1,16 @@
using System; namespace AsterNET.Manager.Action
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace AsterNET.Manager.Action
{ {
public class QueueReloadAction : ManagerAction public class QueueReloadAction : ManagerAction
{ {
private string _queue;
private string _members;
private string _rules;
private string _parameters;
/// <summary> /// <summary>
/// Reload a queue, queues, or any sub-section of a queue or queues. /// Reload a queue, queues, or any sub-section of a queue or queues.
/// </summary> /// </summary>
public QueueReloadAction() public QueueReloadAction()
{ {
} }
/// <summary> /// <summary>
/// Reload a queue, queues, or any sub-section of a queue or queues. /// Reload a queue, queues, or any sub-section of a queue or queues.
/// </summary> /// </summary>
/// <param name="queue"></param> /// <param name="queue"></param>
/// <param name="members"></param> /// <param name="members"></param>
@ -29,10 +18,10 @@ namespace AsterNET.Manager.Action
/// <param name="parameters"></param> /// <param name="parameters"></param>
public QueueReloadAction(string queue, string members, string rules, string parameters) public QueueReloadAction(string queue, string members, string rules, string parameters)
{ {
_queue = queue; Queue = queue;
_members = members; Members = members;
_rules = rules; Rules = rules;
_parameters = parameters; Parameters = parameters;
} }
public override string Action public override string Action
@ -40,28 +29,12 @@ namespace AsterNET.Manager.Action
get { return "QueueReload"; } get { return "QueueReload"; }
} }
public string Queue public string Queue { get; set; }
{
get { return _queue; }
set { _queue = value; }
}
public string Members public string Members { get; set; }
{
get { return _members; }
set { _members = value; }
}
public string Rules public string Rules { get; set; }
{
get { return _rules; }
set { _rules = value; }
}
public string Parameters public string Parameters { get; set; }
{
get { return _parameters; }
set { _parameters = value; }
}
} }
} }

View file

@ -1,62 +1,46 @@
using System;
namespace AsterNET.Manager.Action namespace AsterNET.Manager.Action
{ {
/// <summary> /// <summary>
/// The QueueRemoveAction removes a member from a queue.<br/> /// The QueueRemoveAction removes a member from a queue.<br />
/// It is implemented in <code>apps/app_queue.c</code> /// It is implemented in <code>apps/app_queue.c</code>
/// </summary> /// </summary>
public class QueueRemoveAction : ManagerAction public class QueueRemoveAction : ManagerAction
{ {
/// <summary> The name of the queue the member will be removed from.</summary> /// <summary>
private string queue; /// Creates a new empty QueueRemoveAction.
private string iface; /// </summary>
public QueueRemoveAction()
{
}
/// <summary> /// <summary>
/// Get the name of this action, i.e. "QueueRemove". /// Creates a new QueueRemoveAction that removes the member on the given interface from the given queue.
/// </summary> /// </summary>
override public string Action /// <param name="queue">the name of the queue the member will be removed from</param>
{ /// <param name="iface">the interface of the member to remove</param>
get public QueueRemoveAction(string queue, string iface)
{ {
return "QueueRemove"; this.Queue = queue;
} this.Interface = iface;
}
}
/// <summary> /// <summary>
/// Get/Set the name of the queue the member will be removed from. /// Get the name of this action, i.e. "QueueRemove".
/// </summary> /// </summary>
public string Queue public override string Action
{ {
get { return this.queue; } get { return "QueueRemove"; }
set { this.queue = value; } }
}
/// <summary> /// <summary>
/// Get/Set the interface to remove.<br/> /// Get/Set the name of the queue the member will be removed from.
/// This property is mandatory. /// </summary>
/// </summary> public string Queue { get; set; }
public string Interface
{ /// <summary>
get { return this.iface; } /// Get/Set the interface to remove.<br />
set { this.iface = value; } /// This property is mandatory.
} /// </summary>
public string Interface { get; set; }
/// <summary> }
/// Creates a new empty QueueRemoveAction.
/// </summary>
public QueueRemoveAction()
{
}
/// <summary>
/// Creates a new QueueRemoveAction that removes the member on the given interface from the given queue.
/// </summary>
/// <param name="queue">the name of the queue the member will be removed from</param>
/// <param name="iface">the interface of the member to remove</param>
public QueueRemoveAction(string queue, string iface)
{
this.queue = queue;
this.iface = iface;
}
}
} }

View file

@ -1,29 +1,21 @@
using System; namespace AsterNET.Manager.Action
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace AsterNET.Manager.Action
{ {
public class QueueResetAction : ManagerAction public class QueueResetAction : ManagerAction
{ {
private string _queue;
/// <summary> /// <summary>
/// Reset queue statistics. /// Reset queue statistics.
/// </summary> /// </summary>
public QueueResetAction() public QueueResetAction()
{ {
} }
/// <summary> /// <summary>
/// Reset queue statistics. /// Reset queue statistics.
/// </summary> /// </summary>
/// <param name="queue"></param> /// <param name="queue"></param>
public QueueResetAction(string queue) public QueueResetAction(string queue)
{ {
_queue = queue; Queue = queue;
} }
public override string Action public override string Action
@ -31,10 +23,6 @@ namespace AsterNET.Manager.Action
get { return "QueueReset"; } get { return "QueueReset"; }
} }
public string Queue public string Queue { get; set; }
{
get { return _queue; }
set { _queue = value; }
}
} }
} }

View file

@ -1,22 +1,14 @@
using System; namespace AsterNET.Manager.Action
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace AsterNET.Manager.Action
{ {
public class QueueRuleAction : ManagerAction public class QueueRuleAction : ManagerAction
{ {
private string _rule;
public QueueRuleAction() public QueueRuleAction()
{ {
} }
public QueueRuleAction(string rule) public QueueRuleAction(string rule)
{ {
_rule = rule; Rule = rule;
} }
public override string Action public override string Action
@ -24,10 +16,6 @@ namespace AsterNET.Manager.Action
get { return "QueueRule"; } get { return "QueueRule"; }
} }
public string Rule public string Rule { get; set; }
{
get { return _rule; }
set { _rule = value; }
}
} }
} }

View file

@ -1,65 +1,63 @@
using System; using System;
using AsterNET.Manager.Event;
namespace AsterNET.Manager.Action namespace AsterNET.Manager.Action
{ {
/// <summary> /// <summary>
/// The QueueStatusAction requests the state of all defined queues their members (agents) and entries (callers).<br/> /// The QueueStatusAction requests the state of all defined queues their members (agents) and entries (callers).<br />
/// For each queue a QueueParamsEvent is generated, followed by a /// For each queue a QueueParamsEvent is generated, followed by a
/// QueueMemberEvent for each member of that queue and a QueueEntryEvent for each /// QueueMemberEvent for each member of that queue and a QueueEntryEvent for each
/// entry in the queue.<br/> /// entry in the queue.<br />
/// Since Asterisk 1.2 a QueueStatusCompleteEvent is sent to denote the end of the generated dump.<br/> /// Since Asterisk 1.2 a QueueStatusCompleteEvent is sent to denote the end of the generated dump.<br />
/// This action is implemented in <code>apps/app_queue.c</code> /// This action is implemented in <code>apps/app_queue.c</code>
/// </summary> /// </summary>
/// <seealso cref="Manager.event.QueueParamsEvent" /> /// <seealso cref="Manager.event.QueueParamsEvent" />
/// <seealso cref="Manager.event.QueueMemberEvent" /> /// <seealso cref="Manager.event.QueueMemberEvent" />
/// <seealso cref="Manager.event.QueueEntryEvent" /> /// <seealso cref="Manager.event.QueueEntryEvent" />
/// <seealso cref="Manager.event.QueueStatusCompleteEvent" /> /// <seealso cref="Manager.event.QueueStatusCompleteEvent" />
public class QueueStatusAction : ManagerActionEvent public class QueueStatusAction : ManagerActionEvent
{ {
private string queue; #region Action
private string member;
#region Action /// <summary>
/// <summary> /// Get the name of this action, i.e. "QueueStatus".
/// Get the name of this action, i.e. "QueueStatus". /// </summary>
/// </summary> public override string Action
public override string Action {
{ get { return "QueueStatus"; }
get { return "QueueStatus"; } }
}
#endregion
#region Queue
/// <summary>
/// Get/Set the queue filter.
/// </summary>
public string Queue
{
get { return queue; }
set { this.queue = value; }
}
#endregion
#region Member
/// <summary>
/// Get/Set the member filter.
/// </summary>
public string Member
{
get { return member; }
set { this.member = value; }
}
#endregion
#region ActionCompleteEventClass #endregion
public override Type ActionCompleteEventClass()
{
return typeof(Event.QueueStatusCompleteEvent);
}
#endregion
#region QueueStatusAction() #region Queue
/// <summary> Creates a new QueueStatusAction.</summary>
public QueueStatusAction() /// <summary>
{ /// Get/Set the queue filter.
} /// </summary>
#endregion public string Queue { get; set; }
}
#endregion
#region Member
/// <summary>
/// Get/Set the member filter.
/// </summary>
public string Member { get; set; }
#endregion
#region ActionCompleteEventClass
public override Type ActionCompleteEventClass()
{
return typeof (QueueStatusCompleteEvent);
}
#endregion
#region QueueStatusAction()
#endregion
}
} }

View file

@ -1,102 +1,79 @@
using System;
namespace AsterNET.Manager.Action namespace AsterNET.Manager.Action
{ {
/// <summary> /// <summary>
/// Redirects a given channel (and an optional additional channel) to a new extension. /// Redirects a given channel (and an optional additional channel) to a new extension.
/// </summary> /// </summary>
public class RedirectAction : ManagerAction public class RedirectAction : ManagerAction
{ {
private string channel; /// <summary>
private string extraChannel; /// Creates a new empty RedirectAction.
private string exten; /// </summary>
private string context; public RedirectAction()
private int priority; {
}
/// <summary> /// <summary>
/// Get the name of this action, i.e. "Redirect". /// Creates a new RedirectAction that redirects the given channel to the given context, extension, priority triple.
/// </summary> /// </summary>
override public string Action /// <param name="channel">the name of the channel to redirect</param>
{ /// <param name="context">the destination context</param>
get { return "Redirect"; } /// <param name="exten">the destination extension</param>
} /// <param name="priority">the destination priority</param>
/// <summary> public RedirectAction(string channel, string context, string exten, int priority)
/// Get/Set name of the channel to redirect. {
public string Channel this.Channel = channel;
{ this.Context = context;
get { return this.channel; } this.Exten = exten;
set { this.channel = value; } this.Priority = priority;
} }
/// <summary>
/// Get/Set the name of the additional channel to redirect.
/// </summary>
public string ExtraChannel
{
get { return this.extraChannel; }
set { this.extraChannel = value; }
}
/// <summary>
/// Get/Set the destination context.
/// </summary>
public string Context
{
get { return this.context; }
set { this.context = value; }
}
/// <summary>
/// Get/Set the destination extension.
/// </summary>
public string Exten
{
get { return this.exten; }
set { this.exten = value; }
}
/// <summary>
/// Get/Set the destination priority.
/// </summary>
public int Priority
{
get { return this.priority; }
set { this.priority = value; }
}
/// <summary>
/// Creates a new empty RedirectAction.
/// </summary>
public RedirectAction()
{
}
/// <summary> /// <summary>
/// Creates a new RedirectAction that redirects the given channel to the given context, extension, priority triple. /// Creates a new RedirectAction that redirects the given channels to the given context, extension, priority triple.
/// </summary> /// </summary>
/// <param name="channel">the name of the channel to redirect</param> /// <param name="channel">the name of the first channel to redirect</param>
/// <param name="context">the destination context</param> /// <param name="extraChannel">the name of the second channel to redirect</param>
/// <param name="exten">the destination extension</param> /// <param name="context">the destination context</param>
/// <param name="priority">the destination priority</param> /// <param name="exten">the destination extension</param>
public RedirectAction(string channel, string context, string exten, int priority) /// <param name="priority">the destination priority</param>
{ public RedirectAction(string channel, string extraChannel, string context, string exten, int priority)
this.channel = channel; {
this.context = context; this.Channel = channel;
this.exten = exten; this.ExtraChannel = extraChannel;
this.priority = priority; this.Context = context;
} this.Exten = exten;
this.Priority = priority;
/// <summary> }
/// Creates a new RedirectAction that redirects the given channels to the given context, extension, priority triple.
/// </summary> /// <summary>
/// <param name="channel">the name of the first channel to redirect</param> /// Get the name of this action, i.e. "Redirect".
/// <param name="extraChannel">the name of the second channel to redirect</param> /// </summary>
/// <param name="context">the destination context</param> public override string Action
/// <param name="exten">the destination extension</param> {
/// <param name="priority">the destination priority</param> get { return "Redirect"; }
public RedirectAction(string channel, string extraChannel, string context, string exten, int priority) }
{
this.channel = channel; /// <summary>
this.extraChannel = extraChannel; /// Get/Set name of the channel to redirect.
this.context = context; public string Channel { get; set; }
this.exten = exten;
this.priority = priority; /// <summary>
} /// Get/Set the name of the additional channel to redirect.
} /// </summary>
public string ExtraChannel { get; set; }
/// <summary>
/// Get/Set the destination context.
/// </summary>
public string Context { get; set; }
/// <summary>
/// Get/Set the destination extension.
/// </summary>
public string Exten { get; set; }
/// <summary>
/// Get/Set the destination priority.
/// </summary>
public int Priority { get; set; }
}
} }

View file

@ -1,31 +1,26 @@
using System; using System;
using AsterNET.Manager.Event;
namespace AsterNET.Manager.Action namespace AsterNET.Manager.Action
{ {
/// <summary> /// <summary>
/// Retrieves a list of all defined SIP peers.<br/> /// Retrieves a list of all defined SIP peers.<br />
/// For each peer that is found a PeerEntryEvent is sent by Asterisk containing /// For each peer that is found a PeerEntryEvent is sent by Asterisk containing
/// the details. When all peers have been reported a PeerlistCompleteEvent is sent.<br/> /// the details. When all peers have been reported a PeerlistCompleteEvent is sent.<br />
/// Available since Asterisk 1.2 /// Available since Asterisk 1.2
/// </summary> /// </summary>
/// <seealso cref="Manager.event.PeerEntryEvent" /> /// <seealso cref="Manager.event.PeerEntryEvent" />
/// <seealso cref="Manager.event.PeerlistCompleteEvent" /> /// <seealso cref="Manager.event.PeerlistCompleteEvent" />
public class SIPPeersAction : ManagerActionEvent public class SIPPeersAction : ManagerActionEvent
{ {
public override string Action public override string Action
{ {
get { return "SIPPeers"; } get { return "SIPPeers"; }
} }
public override Type ActionCompleteEventClass()
{ public override Type ActionCompleteEventClass()
return typeof(Event.PeerlistCompleteEvent); {
} return typeof (PeerlistCompleteEvent);
}
/// <summary> }
/// Creates a new SIPPeersAction.
/// </summary>
public SIPPeersAction()
{
}
}
} }

View file

@ -1,48 +1,45 @@
using System; using System;
using AsterNET.Manager.Event;
namespace AsterNET.Manager.Action namespace AsterNET.Manager.Action
{ {
/// <summary> /// <summary>
/// Retrieves a the details about a given SIP peer.<br/> /// Retrieves a the details about a given SIP peer.<br />
/// For a PeerEntryEvent is sent by Asterisk containing the details of the peer /// For a PeerEntryEvent is sent by Asterisk containing the details of the peer
/// followed by a PeerlistCompleteEvent.<br/> /// followed by a PeerlistCompleteEvent.<br />
/// Available since Asterisk 1.2 /// Available since Asterisk 1.2
/// </summary> /// </summary>
/// <seealso cref="Manager.event.PeerEntryEvent" /> /// <seealso cref="Manager.event.PeerEntryEvent" />
/// <seealso cref="Manager.event.PeerlistCompleteEvent" /> /// <seealso cref="Manager.event.PeerlistCompleteEvent" />
public class SIPShowPeerAction : ManagerActionEvent public class SIPShowPeerAction : ManagerActionEvent
{ {
private string peer; /// <summary> Creates a new empty SIPShowPeerAction.</summary>
public SIPShowPeerAction()
{
}
override public string Action /// <summary>
{ /// Creates a new SIPShowPeerAction that requests the details about the given SIP peer.
get { return "SIPShowPeer"; } /// </summary>
} public SIPShowPeerAction(string peer)
/// <summary> {
/// Get/Set the name of the peer to retrieve.<br/> this.Peer = peer;
/// This parameter is mandatory. }
/// </summary>
public string Peer public override string Action
{ {
get { return this.peer; } get { return "SIPShowPeer"; }
set { this.peer = value; } }
}
public override Type ActionCompleteEventClass() /// <summary>
{ /// Get/Set the name of the peer to retrieve.<br />
return typeof(Event.PeerlistCompleteEvent); /// This parameter is mandatory.
} /// </summary>
public string Peer { get; set; }
/// <summary> Creates a new empty SIPShowPeerAction.</summary>
public SIPShowPeerAction() public override Type ActionCompleteEventClass()
{ {
} return typeof (PeerlistCompleteEvent);
}
/// <summary> }
/// Creates a new SIPShowPeerAction that requests the details about the given SIP peer.
/// </summary>
public SIPShowPeerAction(string peer)
{
this.peer = peer;
}
}
} }

View file

@ -1,81 +1,70 @@
using System;
namespace AsterNET.Manager.Action namespace AsterNET.Manager.Action
{ {
/// <summary> /// <summary>
/// The SetCDRUserFieldAction causes the user field of the call detail record for the given channel to be changed.<br/> /// The SetCDRUserFieldAction causes the user field of the call detail record for the given channel to be changed.
/// Depending on the value of the append property the value is appended or overwritten.<br/> /// <br />
/// The SetCDRUserFieldAction is implemented in <code>apps/app_setcdruserfield.c</code> /// Depending on the value of the append property the value is appended or overwritten.<br />
/// </summary> /// The SetCDRUserFieldAction is implemented in <code>apps/app_setcdruserfield.c</code>
public class SetCDRUserFieldAction : ManagerAction /// </summary>
{ public class SetCDRUserFieldAction : ManagerAction
private string channel; {
private string userField; /// <summary>
private bool append; /// Creates a new empty SetCDRUserFieldAction.
/// </summary>
public SetCDRUserFieldAction()
{
}
/// <summary> /// <summary>
/// Get the name of the action, i.e. "SetCDRUserField". /// Creates a new SetCDRUserFieldAction that sets the user field of the call detail record for the given channel to the
/// </summary> /// given value.
override public string Action /// </summary>
{ /// <param name="channel">the name of the channel</param>
get { return "SetCDRUserField"; } /// <param name="userField">the new value of the userfield</param>
} public SetCDRUserFieldAction(string channel, string userField)
/// <summary> {
/// Get/Set the name of the channel to set the cdr user field on.<br/> this.Channel = channel;
/// This property is mandatory. this.UserField = userField;
/// </summary> }
public string Channel
{ /// <summary>
get { return this.channel; } /// Creates a new SetCDRUserFieldAction that sets the user field of the call detail record for the given channel to the
set { this.channel = value; } /// given value.
} /// </summary>
/// <summary> /// <param name="channel">the name of the channel</param>
/// Get/Set the value of the cdr user field to set or append.<br/> /// <param name="userField">the new value of the userfield</param>
/// This property is mandatory. /// <param name="append">true to append the value to the cdr user field or false to overwrite</param>
/// </summary> public SetCDRUserFieldAction(string channel, string userField, bool append)
public string UserField {
{ this.Channel = channel;
get { return this.userField; } this.UserField = userField;
set { this.userField = value; } this.Append = append;
} }
/// <summary>
/// Get/Set if the value of the cdr user field is appended or overwritten.<br/> /// <summary>
/// <code>true</code> to append the value to the cdr user field or <code>false</code> to overwrite. /// Get the name of the action, i.e. "SetCDRUserField".
/// </summary> /// </summary>
public bool Append public override string Action
{ {
get { return this.append; } get { return "SetCDRUserField"; }
set { this.append = value; } }
}
/// <summary> /// <summary>
/// Creates a new empty SetCDRUserFieldAction. /// Get/Set the name of the channel to set the cdr user field on.<br />
/// </summary> /// This property is mandatory.
public SetCDRUserFieldAction() /// </summary>
{ public string Channel { get; set; }
}
/// <summary>
/// <summary> /// Get/Set the value of the cdr user field to set or append.<br />
/// Creates a new SetCDRUserFieldAction that sets the user field of the call detail record for the given channel to the given value. /// This property is mandatory.
/// </summary> /// </summary>
/// <param name="channel">the name of the channel</param> public string UserField { get; set; }
/// <param name="userField">the new value of the userfield</param>
public SetCDRUserFieldAction(string channel, string userField) /// <summary>
{ /// Get/Set if the value of the cdr user field is appended or overwritten.<br />
this.channel = channel; /// <code>true</code> to append the value to the cdr user field or <code>false</code> to overwrite.
this.userField = userField; /// </summary>
} public bool Append { get; set; }
}
/// <summary>
/// Creates a new SetCDRUserFieldAction that sets the user field of the call detail record for the given channel to the given value.
/// </summary>
/// <param name="channel">the name of the channel</param>
/// <param name="userField">the new value of the userfield</param>
/// <param name="append">true to append the value to the cdr user field or false to overwrite</param>
public SetCDRUserFieldAction(string channel, string userField, bool append)
{
this.channel = channel;
this.userField = userField;
this.append = append;
}
}
} }

View file

@ -1,81 +1,84 @@
using System;
namespace AsterNET.Manager.Action namespace AsterNET.Manager.Action
{ {
/// <summary> /// <summary>
/// The SetVar action sets the value of a channel variable for a given channel. /// The SetVar action sets the value of a channel variable for a given channel.
/// </summary> /// </summary>
public class SetVarAction : ManagerAction public class SetVarAction : ManagerAction
{ {
/// <summary> The channel on which to set the variable.</summary> /// <summary> The channel on which to set the variable.</summary>
public string channel; public string channel;
/// <summary> The name of the variable to set.</summary>
public string varName;
/// <summary> The value to store.</summary>
public string varValue;
/// <summary> /// <summary> The name of the variable to set.</summary>
/// Get the name of this action, i.e. "SetVar". public string varName;
/// </summary>
override public string Action
{
get { return "SetVar"; }
}
/// <summary>
/// Get/Set the name of the channel.
/// </summary>
public string Channel
{
get { return channel; }
set { this.channel = value; }
}
/// <summary>
/// Get/Set the name of the variable to set.
/// </summary>
public string Variable
{
get { return this.varName; }
set { this.varName = value; }
}
/// <summary>
/// Get/Set the value to store.
/// </summary>
public string Value
{
get { return this.varValue; }
set { this.varValue = value; }
}
/// <summary>
/// Creates a new empty SetVarAction.
/// </summary>
public SetVarAction()
{
}
/// <summary> /// <summary> The value to store.</summary>
/// Creates a new SetVarAction that sets the given global variable to a new value. public string varValue;
/// </summary>
/// <param name="variable">the name of the global variable to set</param>
/// <param name="value">the new value</param>
public SetVarAction(string variable, string value)
{
this.varName = variable;
this.varValue = value;
}
/// <summary> /// <summary>
/// Creates a new SetVarAction that sets the given channel variable of the /// Creates a new empty SetVarAction.
/// given channel to a new value. /// </summary>
/// </summary> public SetVarAction()
/// <param name="channel">the name of the channel to set the variable on</param> {
/// <param name="variable">the name of the channel variable</param> }
/// <param name="value">the new value</param>
public SetVarAction(string channel, string variable, string value) /// <summary>
{ /// Creates a new SetVarAction that sets the given global variable to a new value.
this.channel = channel; /// </summary>
this.varName = variable; /// <param name="variable">the name of the global variable to set</param>
this.varValue = value; /// <param name="value">the new value</param>
} public SetVarAction(string variable, string value)
} {
varName = variable;
varValue = value;
}
/// <summary>
/// Creates a new SetVarAction that sets the given channel variable of the
/// given channel to a new value.
/// </summary>
/// <param name="channel">the name of the channel to set the variable on</param>
/// <param name="variable">the name of the channel variable</param>
/// <param name="value">the new value</param>
public SetVarAction(string channel, string variable, string value)
{
this.channel = channel;
varName = variable;
varValue = value;
}
/// <summary>
/// Get the name of this action, i.e. "SetVar".
/// </summary>
public override string Action
{
get { return "SetVar"; }
}
/// <summary>
/// Get/Set the name of the channel.
/// </summary>
public string Channel
{
get { return channel; }
set { channel = value; }
}
/// <summary>
/// Get/Set the name of the variable to set.
/// </summary>
public string Variable
{
get { return varName; }
set { varName = value; }
}
/// <summary>
/// Get/Set the value to store.
/// </summary>
public string Value
{
get { return varValue; }
set { varValue = value; }
}
}
} }

View file

@ -1,33 +1,28 @@
using System; using System;
using AsterNET.Manager.Event;
namespace AsterNET.Manager.Action namespace AsterNET.Manager.Action
{ {
/// <summary> /// <summary>
/// The StatusAction requests the state of all active channels.<br/> /// The StatusAction requests the state of all active channels.<br />
/// For each active channel a StatusEvent is generated. After the state of all /// For each active channel a StatusEvent is generated. After the state of all
/// channels has been reported a StatusCompleteEvent is generated. /// channels has been reported a StatusCompleteEvent is generated.
/// </summary> /// </summary>
/// <seealso cref="Manager.event.StatusEvent" /> /// <seealso cref="Manager.event.StatusEvent" />
/// <seealso cref="Manager.event.StatusCompleteEvent" /> /// <seealso cref="Manager.event.StatusCompleteEvent" />
public class StatusAction : ManagerActionEvent public class StatusAction : ManagerActionEvent
{ {
/// <summary> /// <summary>
/// Get the name of this action, i.e. "Status". /// Get the name of this action, i.e. "Status".
/// </summary> /// </summary>
public override string Action public override string Action
{ {
get { return "Status"; } get { return "Status"; }
} }
public override Type ActionCompleteEventClass()
{ public override Type ActionCompleteEventClass()
return typeof(Event.StatusCompleteEvent); {
} return typeof (StatusCompleteEvent);
}
/// <summary> }
/// Creates a new StatusAction.
/// </summary>
public StatusAction()
{
}
}
} }

View file

@ -1,53 +1,54 @@
using System;
namespace AsterNET.Manager.Action namespace AsterNET.Manager.Action
{ {
/// <summary> /// <summary>
/// The StopMonitorAction ends monitoring (recording) a channel.<br/> /// The StopMonitorAction ends monitoring (recording) a channel.<br />
/// It is implemented in <code>res/res_monitor.c</code> /// It is implemented in <code>res/res_monitor.c</code>
/// </summary> /// </summary>
public class StopMonitorAction : ManagerAction public class StopMonitorAction : ManagerAction
{ {
/// <summary> The name of the channel to end monitoring.</summary> #region Action
private string channel;
#region Action /// <summary>
/// <summary> /// Get the name of this action, i.e. "StopMonitor".
/// Get the name of this action, i.e. "StopMonitor". /// </summary>
/// </summary> public override string Action
override public string Action {
{ get { return "StopMonitor"; }
get { return "StopMonitor"; } }
}
#endregion #endregion
#region Channel
/// <summary> #region Channel
/// Get/Set the name of the channel to end monitoring.<br/>
/// This property is mandatory. /// <summary>
/// </summary> /// Get/Set the name of the channel to end monitoring.<br />
public string Channel /// This property is mandatory.
{ /// </summary>
get { return this.channel; } public string Channel { get; set; }
set { this.channel = value; }
} #endregion
#endregion
#region StopMonitorAction()
#region StopMonitorAction()
/// <summary> /// <summary>
/// Creates a new empty StopMonitorAction. /// Creates a new empty StopMonitorAction.
/// </summary> /// </summary>
public StopMonitorAction() public StopMonitorAction()
{ {
} }
#endregion
#region StopMonitorAction(string channel) #endregion
/// <summary>
/// Creates a new StopMonitorAction that ends monitoring of the given channel. #region StopMonitorAction(string channel)
/// </summary>
public StopMonitorAction(string channel) /// <summary>
{ /// Creates a new StopMonitorAction that ends monitoring of the given channel.
this.channel = channel; /// </summary>
} public StopMonitorAction(string channel)
#endregion {
} this.Channel = channel;
}
#endregion
}
} }

View file

@ -1,198 +1,185 @@
using System;
using AsterNET.Manager.Response;
using System.Collections.Generic; using System.Collections.Generic;
using AsterNET.Manager.Response;
namespace AsterNET.Manager.Action namespace AsterNET.Manager.Action
{ {
/// <summary> /// <summary>
/// The UpdateConfigAction sends an UpdateConfig command to the asterisk server. /// The UpdateConfigAction sends an UpdateConfig command to the asterisk server.
/// Please take note that unlike the manager documentation, this command does not /// Please take note that unlike the manager documentation, this command does not
/// dump back the config file upon success -- it only tells you it succeeded. You /// dump back the config file upon success -- it only tells you it succeeded. You
/// should use the handy addCommand method this class provides for specifying /// should use the handy addCommand method this class provides for specifying
/// what actions you would like to take on the configuration file. It will /// what actions you would like to take on the configuration file. It will
/// generate appropriate sequence numbers for the command. You may use the static /// generate appropriate sequence numbers for the command. You may use the static
/// ACTION_* fields provided by this action to specify what action you would like /// ACTION_* fields provided by this action to specify what action you would like
/// to take, while avoiding handling the strings required. Plain fields:<br/> /// to take, while avoiding handling the strings required. Plain fields:<br />
/// SrcFilename: Configuration filename to read(e.g. foo.conf)<br/> /// SrcFilename: Configuration filename to read(e.g. foo.conf)<br />
/// DstFilename: Configuration filename to write(e.g. foo.conf)<br/> /// DstFilename: Configuration filename to write(e.g. foo.conf)<br />
/// Reload: Whether or not a reload should take place (or name of specific module)<br/> /// Reload: Whether or not a reload should take place (or name of specific module)<br />
/// Repeatable fields:<br/> /// Repeatable fields:<br />
/// Action-XXXXXX: Action to Take (NewCat,RenameCat,DelCat,Update,Delete,Append)<br/> /// Action-XXXXXX: Action to Take (NewCat,RenameCat,DelCat,Update,Delete,Append)<br />
/// Cat-XXXXXX: Category to operate on<br/> /// Cat-XXXXXX: Category to operate on<br />
/// Var-XXXXXX: Variable to work on<br/> /// Var-XXXXXX: Variable to work on<br />
/// Value-XXXXXX: Value to work on<br/> /// Value-XXXXXX: Value to work on<br />
/// Match-XXXXXX: Extra match required to match line /// Match-XXXXXX: Extra match required to match line
/// </summary> /// </summary>
public class UpdateConfigAction : ManagerActionResponse public class UpdateConfigAction : ManagerActionResponse
{ {
public const string ACTION_NEWCAT = "newcat"; public const string ACTION_NEWCAT = "newcat";
public const string ACTION_RENAMECAT = "renamecat"; public const string ACTION_RENAMECAT = "renamecat";
public const string ACTION_DELCAT = "delcat"; public const string ACTION_DELCAT = "delcat";
public const string ACTION_UPDATE = "update"; public const string ACTION_UPDATE = "update";
public const string ACTION_DELETE = "delete"; public const string ACTION_DELETE = "delete";
public const string ACTION_APPEND = "append"; public const string ACTION_APPEND = "append";
private string reload; private readonly Dictionary<string, string> actions;
private string srcFileName; private int actionCounter;
private string dstFileName;
private int actionCounter;
private Dictionary<string, string> actions;
/// <summary> /// <summary>
/// Creates a new UpdateConfigAction. /// Creates a new UpdateConfigAction.
/// </summary> /// </summary>
public UpdateConfigAction() public UpdateConfigAction()
: base() {
{ actionCounter = 0;
actionCounter = 0; actions = new Dictionary<string, string>();
actions = new Dictionary<string,string>(); }
}
/// <summary> /// <summary>
/// Creates a new UpdateConfigAction. /// Creates a new UpdateConfigAction.
/// </summary> /// </summary>
public UpdateConfigAction(string srcFilename, string dstFilename, string reload) public UpdateConfigAction(string srcFilename, string dstFilename, string reload)
: this() : this()
{ {
this.srcFileName = srcFilename; SrcFileName = srcFilename;
this.dstFileName = dstFilename; DstFileName = dstFilename;
this.reload = reload; this.Reload = reload;
} }
/// <summary> /// <summary>
/// Creates a new UpdateConfigAction. /// Creates a new UpdateConfigAction.
/// </summary> /// </summary>
public UpdateConfigAction(string srcFilename, string dstFilename, bool reload) public UpdateConfigAction(string srcFilename, string dstFilename, bool reload)
: this() : this()
{ {
this.srcFileName = srcFilename; SrcFileName = srcFilename;
this.dstFileName = dstFilename; DstFileName = dstFilename;
this.reload = (reload ? "true" : ""); this.Reload = (reload ? "true" : "");
} }
/// <summary> /// <summary>
/// Creates a new UpdateConfigAction. /// Creates a new UpdateConfigAction.
/// </summary> /// </summary>
public UpdateConfigAction(string srcFilename, string dstFilename) public UpdateConfigAction(string srcFilename, string dstFilename)
: this() : this()
{ {
this.srcFileName = srcFilename; SrcFileName = srcFilename;
this.dstFileName = dstFilename; DstFileName = dstFilename;
this.reload = ""; Reload = "";
} }
/// <summary> /// <summary>
/// Get/Set the destination filename. /// Get/Set the destination filename.
/// </summary> /// </summary>
public string DstFileName public string DstFileName { get; set; }
{
get { return dstFileName; }
set { dstFileName = value; }
}
/// <summary>
/// Get/Set the source filename.
/// </summary>
public string SrcFileName
{
get { return srcFileName; }
set { srcFileName = value; }
}
/// <summary>
/// Get/Set the reload behavior of this action (yes), or sets a specific module (name) to be reloaded.<br/>
/// Set to empty string to update without reload.
/// </summary>
public string Reload
{
get { return reload; }
set { reload = value; }
}
/// <summary> /// <summary>
/// Get the name of this action. /// Get/Set the source filename.
/// </summary> /// </summary>
public override string Action public string SrcFileName { get; set; }
{
get { return "UpdateConfig"; }
}
#region AddCommand(...) /// <summary>
/// <summary> /// Get/Set the reload behavior of this action (yes), or sets a specific module (name) to be reloaded.<br />
/// Adds a command to update a config file while sparing you the details of /// Set to empty string to update without reload.
/// the Manager's required syntax. If you want to omit one of the command's /// </summary>
/// sections, provide a null value to this method. The command index will be public string Reload { get; set; }
/// incremented even if you supply a null for all parameters, though the action
/// will be unaffected. /// <summary>
/// </summary> /// Get the name of this action.
/// <param name="action">Action to Take (NewCat,RenameCat,DelCat,Update,Delete,Append)</param> /// </summary>
/// <param name="category">Category to operate on</param> public override string Action
/// <param name="variable">Variable to work on</param> {
/// <param name="value">Value to work on</param> get { return "UpdateConfig"; }
/// <param name="match">Extra match required to match line</param> }
public void AddCommand(string action, string category, string variable, string value, string match)
{ #region AddCommand(...)
var i = actionCounter++;
/// <summary>
/// Adds a command to update a config file while sparing you the details of
/// the Manager's required syntax. If you want to omit one of the command's
/// sections, provide a null value to this method. The command index will be
/// incremented even if you supply a null for all parameters, though the action
/// will be unaffected.
/// </summary>
/// <param name="action">Action to Take (NewCat,RenameCat,DelCat,Update,Delete,Append)</param>
/// <param name="category">Category to operate on</param>
/// <param name="variable">Variable to work on</param>
/// <param name="value">Value to work on</param>
/// <param name="match">Extra match required to match line</param>
public void AddCommand(string action, string category, string variable, string value, string match)
{
var i = actionCounter++;
var index = i.ToString().PadLeft(6, '0'); var index = i.ToString().PadLeft(6, '0');
if (!string.IsNullOrEmpty(action)) if (!string.IsNullOrEmpty(action))
actions.Add("Action-" + index, action); actions.Add("Action-" + index, action);
if (!string.IsNullOrEmpty(category)) if (!string.IsNullOrEmpty(category))
actions.Add("Cat-" + index, category); actions.Add("Cat-" + index, category);
if (!string.IsNullOrEmpty(variable)) if (!string.IsNullOrEmpty(variable))
actions.Add("Var-" + index, variable); actions.Add("Var-" + index, variable);
if (!string.IsNullOrEmpty(value)) if (!string.IsNullOrEmpty(value))
actions.Add("Value-" + index, value); actions.Add("Value-" + index, value);
if (!string.IsNullOrEmpty(match)) if (!string.IsNullOrEmpty(match))
actions.Add("Match-" + index, match); actions.Add("Match-" + index, match);
} }
public void AddCommand(string action, string category, string variable, string value) public void AddCommand(string action, string category, string variable, string value)
{ {
AddCommand(action, category, variable, value, null); AddCommand(action, category, variable, value, null);
} }
public void AddCommand(string action, string category, string variable) public void AddCommand(string action, string category, string variable)
{ {
AddCommand(action, category, variable, null, null); AddCommand(action, category, variable, null, null);
} }
public void AddCommand(string action, string category) public void AddCommand(string action, string category)
{ {
AddCommand(action, category, null, null, null); AddCommand(action, category, null, null, null);
} }
public void AddCommand(string action) public void AddCommand(string action)
{ {
AddCommand(action, null, null, null, null); AddCommand(action, null, null, null, null);
} }
public void AddCommand() public void AddCommand()
{ {
AddCommand(null, null, null, null, null); AddCommand(null, null, null, null, null);
} }
#endregion
#region Actions #endregion
/// <summary>
/// Dictionary of the action's desired operations where Map keys contain:<br/>
/// action,cat,var,value,match pairs followed by -XXXXXX, and the values contain the values for those keys.
/// This method will typically only be used by the ActionBuilder to generate the actual strings to be sent to the manager interface.
/// </summary>
public Dictionary<string, string> Actions
{
get { return actions; }
}
#endregion
public override object ActionCompleteResponseClass() #region Actions
{
return new ManagerResponse();
}
} /// <summary>
} /// Dictionary of the action's desired operations where Map keys contain:<br />
/// action,cat,var,value,match pairs followed by -XXXXXX, and the values contain the values for those keys.
/// This method will typically only be used by the ActionBuilder to generate the actual strings to be sent to the
/// manager interface.
/// </summary>
public Dictionary<string, string> Actions
{
get { return actions; }
}
#endregion
public override object ActionCompleteResponseClass()
{
return new ManagerResponse();
}
}
}

View file

@ -1,42 +1,37 @@
using System;
namespace AsterNET.Manager.Action namespace AsterNET.Manager.Action
{ {
/// <summary> /// <summary>
/// The ZapDNDOnAction switches a zap channel "Do Not Disturb" status off. /// The ZapDNDOnAction switches a zap channel "Do Not Disturb" status off.
/// </summary> /// </summary>
public class ZapDNDOffAction : ManagerAction public class ZapDNDOffAction : ManagerAction
{ {
private int zapChannel; /// <summary>
/// Creates a new empty ZapDNDOffAction.
/// </summary>
public ZapDNDOffAction()
{
}
/// <summary> /// <summary>
/// Get the name of this action, i.e. "ZapDNDOff". /// Creates a new ZapDNDOffAction that disables "Do Not Disturb" status for the given zap channel.
/// </summary> /// </summary>
override public string Action public ZapDNDOffAction(int zapChannel)
{ {
get { return "ZapDNDOff"; } this.ZapChannel = zapChannel;
} }
/// <summary>
/// Get/Set the number of the zap channel to switch to dnd off.<br/> /// <summary>
/// This property is mandatory. /// Get the name of this action, i.e. "ZapDNDOff".
/// </summary> /// </summary>
public int ZapChannel public override string Action
{ {
get { return this.zapChannel; } get { return "ZapDNDOff"; }
set { this.zapChannel = value; } }
}
/// <summary> /// <summary>
/// Creates a new empty ZapDNDOffAction. /// Get/Set the number of the zap channel to switch to dnd off.<br />
/// </summary> /// This property is mandatory.
public ZapDNDOffAction() /// </summary>
{ public int ZapChannel { get; set; }
} }
/// <summary>
/// Creates a new ZapDNDOffAction that disables "Do Not Disturb" status for the given zap channel.
/// </summary>
public ZapDNDOffAction(int zapChannel)
{
this.zapChannel = zapChannel;
}
}
} }

View file

@ -1,43 +1,37 @@
using System;
namespace AsterNET.Manager.Action namespace AsterNET.Manager.Action
{ {
/// <summary> /// <summary>
/// The ZapDNDOnAction switches a zap channel "Do Not Disturb" status on. /// The ZapDNDOnAction switches a zap channel "Do Not Disturb" status on.
/// </summary> /// </summary>
public class ZapDNDOnAction : ManagerAction public class ZapDNDOnAction : ManagerAction
{ {
private int zapChannel; /// <summary>
/// Creates a new empty ZapDNDOnAction.
/// </summary>
public ZapDNDOnAction()
{
}
/// <summary> /// <summary>
/// Get the name of this action, i.e. "ZapDNDOn". /// Creates a new ZapDNDOnAction that enables "Do Not Disturb" status for the given zap channel.
/// </summary> /// </summary>
override public string Action public ZapDNDOnAction(int zapChannel)
{ {
get { return "ZapDNDOn"; } this.ZapChannel = zapChannel;
} }
/// <summary>
/// Get/Set the number of the zap channel to switch to dnd on.<br/> /// <summary>
/// This property is mandatory. /// Get the name of this action, i.e. "ZapDNDOn".
/// </summary> /// </summary>
public int ZapChannel public override string Action
{ {
get { return this.zapChannel; } get { return "ZapDNDOn"; }
set { this.zapChannel = value; } }
}
/// <summary> /// <summary>
/// Creates a new empty ZapDNDOnAction. /// Get/Set the number of the zap channel to switch to dnd on.<br />
/// </summary> /// This property is mandatory.
public ZapDNDOnAction() /// </summary>
{ public int ZapChannel { get; set; }
} }
/// <summary>
/// Creates a new ZapDNDOnAction that enables "Do Not Disturb" status for the given zap channel.
/// </summary>
public ZapDNDOnAction(int zapChannel)
{
this.zapChannel = zapChannel;
}
}
} }

View file

@ -1,53 +1,42 @@
using System;
namespace AsterNET.Manager.Action namespace AsterNET.Manager.Action
{ {
/// <summary> /// <summary>
/// The ZapDialOffhookAction dials a number on a zap channel while offhook. /// The ZapDialOffhookAction dials a number on a zap channel while offhook.
/// </summary> /// </summary>
public class ZapDialOffhookAction : ManagerAction public class ZapDialOffhookAction : ManagerAction
{ {
private int zapChannel; /// <summary> Creates a new empty ZapDialOffhookAction.</summary>
private string number; public ZapDialOffhookAction()
{
}
/// <summary> /// <summary>
/// Get the name of this action, i.e. "ZapDialOffhook". /// Creates a new ZapDialOffhookAction that dials the given number on the given zap channel.
/// </summary> /// </summary>
override public string Action public ZapDialOffhookAction(int zapChannel, string number)
{ {
get { return "ZapDialOffhook"; } this.ZapChannel = zapChannel;
} this.Number = number;
/// <summary> }
/// Get/Set the number of the zap channel.<br/>
/// This property is mandatory. /// <summary>
/// </summary> /// Get the name of this action, i.e. "ZapDialOffhook".
public int ZapChannel /// </summary>
{ public override string Action
get { return this.zapChannel; } {
set { this.zapChannel = value; } get { return "ZapDialOffhook"; }
} }
/// <summary>
/// Get/Set the number to dial.<br/> /// <summary>
/// This property is mandatory. /// Get/Set the number of the zap channel.<br />
/// </summary> /// This property is mandatory.
public string Number /// </summary>
{ public int ZapChannel { get; set; }
get { return this.number; }
set { this.number = value; } /// <summary>
} /// Get/Set the number to dial.<br />
/// This property is mandatory.
/// <summary> Creates a new empty ZapDialOffhookAction.</summary> /// </summary>
public ZapDialOffhookAction() public string Number { get; set; }
{ }
}
/// <summary>
/// Creates a new ZapDialOffhookAction that dials the given number on the given zap channel.
/// </summary>
public ZapDialOffhookAction(int zapChannel, string number)
{
this.zapChannel = zapChannel;
this.number = number;
}
}
} }

View file

@ -1,44 +1,37 @@
using System;
namespace AsterNET.Manager.Action namespace AsterNET.Manager.Action
{ {
/// <summary> /// <summary>
/// The ZapHangupAction hangs up a zap channel. /// The ZapHangupAction hangs up a zap channel.
/// </summary> /// </summary>
public class ZapHangupAction : ManagerAction public class ZapHangupAction : ManagerAction
{ {
private int zapChannel; /// <summary>
/// Creates a new empty ZapHangupAction.
/// </summary>
public ZapHangupAction()
{
}
/// <summary> /// <summary>
/// Get the name of this action, i.e. "ZapHangup". /// Creates a new ZapHangupAction that hangs up the given zap channel (the number of the zap channel to hang up).
/// </summary> /// </summary>
override public string Action public ZapHangupAction(int zapChannel)
{ {
get { return "ZapHangup"; } this.ZapChannel = zapChannel;
} }
/// <summary>
/// Get/Set the number of the zap channel to hangup.<br/> /// <summary>
/// This property is mandatory. /// Get the name of this action, i.e. "ZapHangup".
/// </summary> /// </summary>
public int ZapChannel public override string Action
{ {
get { return this.zapChannel; } get { return "ZapHangup"; }
set { this.zapChannel = value; } }
}
/// <summary>
/// <summary> /// Get/Set the number of the zap channel to hangup.<br />
/// Creates a new empty ZapHangupAction. /// This property is mandatory.
/// </summary> /// </summary>
public ZapHangupAction() public int ZapChannel { get; set; }
{ }
}
/// <summary>
/// Creates a new ZapHangupAction that hangs up the given zap channel (the number of the zap channel to hang up).
/// </summary>
public ZapHangupAction(int zapChannel)
{
this.zapChannel = zapChannel;
}
}
} }

View file

@ -1,32 +1,28 @@
using System; using System;
using AsterNET.Manager.Event;
namespace AsterNET.Manager.Action namespace AsterNET.Manager.Action
{ {
/// <summary> /// <summary>
/// The ZapShowChannelsAction requests the state of all zap channels.<br/> /// The ZapShowChannelsAction requests the state of all zap channels.<br />
/// For each zap channel a ZapShowChannelsEvent is generated. After all zap /// For each zap channel a ZapShowChannelsEvent is generated. After all zap
/// channels have been listed a ZapShowChannelsCompleteEvent is generated. /// channels have been listed a ZapShowChannelsCompleteEvent is generated.
/// </summary> /// </summary>
/// <seealso cref="Manager.event.ZapShowChannelsEvent" /> /// <seealso cref="Manager.event.ZapShowChannelsEvent" />
/// <seealso cref="Manager.event.ZapShowChannelsCompleteEvent" /> /// <seealso cref="Manager.event.ZapShowChannelsCompleteEvent" />
public class ZapShowChannelsAction : ManagerActionEvent public class ZapShowChannelsAction : ManagerActionEvent
{ {
/// <summary> /// <summary>
/// Get the name of this action, i.e. "ZapShowChannels". /// Get the name of this action, i.e. "ZapShowChannels".
/// </summary> /// </summary>
public override string Action public override string Action
{ {
get { return "ZapShowChannels"; } get { return "ZapShowChannels"; }
} }
public override Type ActionCompleteEventClass()
{ public override Type ActionCompleteEventClass()
return typeof(Event.ZapShowChannelsCompleteEvent); {
} return typeof (ZapShowChannelsCompleteEvent);
}
/// <summary> }
/// Creates a new ZapShowChannelsAction.
/// </summary>
public ZapShowChannelsAction()
{
}
}
} }

View file

@ -1,28 +1,22 @@
using System;
namespace AsterNET.Manager.Action namespace AsterNET.Manager.Action
{ {
/// <summary> /// <summary>
/// The ZapTransferAction transfers a zap channel. /// The ZapTransferAction transfers a zap channel.
/// </summary> /// </summary>
public class ZapTransferAction : ManagerAction public class ZapTransferAction : ManagerAction
{ {
private int zapChannel; /// <summary>
/// Get the name of this action, i.e. "ZapTransfer".
/// </summary>
public override string Action
{
get { return "ZapTransfer"; }
}
/// <summary> /// <summary>
/// Get the name of this action, i.e. "ZapTransfer". /// Get/Set the number of the zap channel to transfer.<br />
/// </summary> /// This property is mandatory.
override public string Action /// </summary>
{ public int ZapChannel { get; set; }
get { return "ZapTransfer"; } }
}
/// <summary>
/// Get/Set the number of the zap channel to transfer.<br/>
/// This property is mandatory.
/// </summary>
public int ZapChannel
{
get { return this.zapChannel; }
set { this.zapChannel = value; }
}
}
} }

View file

@ -1,17 +1,15 @@
using System;
namespace AsterNET.Manager namespace AsterNET.Manager
{ {
public enum AsteriskVersion public enum AsteriskVersion
{ {
ASTERISK_1_0 = 10, ASTERISK_1_0 = 10,
ASTERISK_1_2 = 12, ASTERISK_1_2 = 12,
ASTERISK_1_4 = 14, ASTERISK_1_4 = 14,
ASTERISK_1_6 = 16, ASTERISK_1_6 = 16,
ASTERISK_1_8 = 18, ASTERISK_1_8 = 18,
ASTERISK_10 = 100, ASTERISK_10 = 100,
ASTERISK_11 = 110, ASTERISK_11 = 110,
ASTERISK_12 = 120, ASTERISK_12 = 120,
ASTERISK_13 = 130 ASTERISK_13 = 130
} }
} }

View file

@ -1,51 +1,27 @@
using System;
namespace AsterNET.Manager.Event namespace AsterNET.Manager.Event
{ {
/// <summary> /// <summary>
/// AgiExecEvents are triggered when an AGI command is executed.<br/> /// AgiExecEvents are triggered when an AGI command is executed.<br />
/// For each command two events are triggered: one before excution ("Start") and one after execution ("End"). /// For each command two events are triggered: one before excution ("Start") and one after execution ("End").
/// </summary> /// </summary>
public class AGIExecEvent : ManagerEvent public class AGIExecEvent : ManagerEvent
{ {
private string subEvent; /// <summary>
private long commandId; /// Creates a new AGIExecEvent.
private string command; /// </summary>
private int resultCode; public AGIExecEvent(ManagerConnection source)
private string result; : base(source)
{
}
/// <summary> public long CommandId { get; set; }
/// Creates a new AGIExecEvent.
/// </summary>
public AGIExecEvent(ManagerConnection source)
: base(source)
{
}
public long CommandId public string Command { get; set; }
{
get { return commandId; } public string SubEvent { get; set; }
set { this.commandId = value; }
} public string Result { get; set; }
public string Command
{ public int ResultCode { get; set; }
get { return command; } }
set { this.command = value; } }
}
public string SubEvent
{
get { return subEvent; }
set { this.subEvent = value; }
}
public string Result
{
get { return result; }
set { this.result = value; }
}
public int ResultCode
{
get { return resultCode; }
set { this.resultCode = value; }
}
}
}

View file

@ -1,42 +1,28 @@
namespace AsterNET.Manager.Event namespace AsterNET.Manager.Event
{ {
/// <summary> /// <summary>
/// Abstract base class for several agent related events. /// Abstract base class for several agent related events.
/// </summary> /// </summary>
public abstract class AbstractAgentEvent : AbstractAgentVariables public abstract class AbstractAgentEvent : AbstractAgentVariables
{ {
private string queue; public AbstractAgentEvent(ManagerConnection source)
private string member; : base(source)
private string memberName; {
}
/// <summary> /// <summary>
/// Get/Set the name of the queue. /// Get/Set the name of the queue.
/// </summary> /// </summary>
public string Queue public string Queue { get; set; }
{
get { return queue; }
set { this.queue = value; }
}
/// <summary>
/// Get/Set the name of the member's interface.
/// </summary>
public string Member
{
get { return member; }
set { this.member = value; }
}
/// <summary> /// <summary>
/// Get/Set the name of the member's interface. /// Get/Set the name of the member's interface.
/// </summary> /// </summary>
public string MemberName public string Member { get; set; }
{
get { return memberName; }
set { this.memberName = value; }
}
public AbstractAgentEvent(ManagerConnection source) /// <summary>
: base(source) /// Get/Set the name of the member's interface.
{ } /// </summary>
} public string MemberName { get; set; }
}
} }

View file

@ -1,30 +1,20 @@
namespace AsterNET.Manager.Event namespace AsterNET.Manager.Event
{ {
/// <summary> /// <summary>
/// Abstract base class providing common properties for meet me (asterisk's conference system) events. /// Abstract base class providing common properties for meet me (asterisk's conference system) events.
/// </summary> /// </summary>
public abstract class AbstractMeetmeEvent : ManagerEvent public abstract class AbstractMeetmeEvent : ManagerEvent
{ {
private string meetMe; public AbstractMeetmeEvent(ManagerConnection source)
private int userNum; : base(source)
{
}
/// <summary> /// <summary>
/// Get/Set the conference number. /// Get/Set the conference number.
/// </summary> /// </summary>
public string Meetme public string Meetme { get; set; }
{
get { return meetMe; } public int Usernum { get; set; }
set { this.meetMe = value; } }
}
public int Usernum
{
get { return userNum; }
set { this.userNum = value; }
}
public AbstractMeetmeEvent(ManagerConnection source)
: base(source)
{
}
}
} }

View file

@ -1,50 +1,33 @@
namespace AsterNET.Manager.Event namespace AsterNET.Manager.Event
{ {
/// <summary> /// <summary>
/// Abstract base class for several call parking related events. /// Abstract base class for several call parking related events.
/// </summary> /// </summary>
public abstract class AbstractParkedCallEvent : ManagerEvent public abstract class AbstractParkedCallEvent : ManagerEvent
{ {
private string exten; public AbstractParkedCallEvent(ManagerConnection source)
private string callerId; : base(source)
private string callerIdNum; {
private string callerIdName; }
/// <summary>
/// Get/Set the extension the channel is or was parked at.
/// </summary>
public string Exten
{
get { return this.exten; }
set { this.exten = value; }
}
/// <summary>
/// Get/Set the Caller*ID number of the parked channel.
/// </summary>
public string CallerId
{
get { return this.callerId; }
set { this.callerId = value; }
}
/// <summary>
/// Get/Set the Caller*ID number of the parked channel.
/// </summary>
public string CallerIdNum
{
get { return this.callerIdNum; }
set { this.callerIdNum = value; }
}
/// <summary>
/// Get/Set the Caller*ID name of the parked channel.
/// </summary>
public string CallerIdName
{
get { return this.callerIdName; }
set { this.callerIdName = value; }
}
public AbstractParkedCallEvent(ManagerConnection source) /// <summary>
: base(source) /// Get/Set the extension the channel is or was parked at.
{ } /// </summary>
} public string Exten { get; set; }
/// <summary>
/// Get/Set the Caller*ID number of the parked channel.
/// </summary>
public string CallerId { get; set; }
/// <summary>
/// Get/Set the Caller*ID number of the parked channel.
/// </summary>
public string CallerIdNum { get; set; }
/// <summary>
/// Get/Set the Caller*ID name of the parked channel.
/// </summary>
public string CallerIdName { get; set; }
}
} }

View file

@ -1,33 +1,24 @@
namespace AsterNET.Manager.Event namespace AsterNET.Manager.Event
{ {
/// <summary> /// <summary>
/// Abstract base class for several queue member related events. /// Abstract base class for several queue member related events.
/// </summary> /// </summary>
public abstract class AbstractQueueMemberEvent : ManagerEvent public abstract class AbstractQueueMemberEvent : ManagerEvent
{ {
private string queue; public AbstractQueueMemberEvent(ManagerConnection source)
private string location; : base(source)
{
}
/// <summary> /// <summary>
/// Returns the name of the queue. /// Returns the name of the queue.
/// </summary> /// </summary>
public string Queue public string Queue { get; set; }
{
get { return queue; }
set { this.queue = value; }
}
/// <summary>
/// Returns the name of the member's interface.<br/>
/// E.g. the channel name or agent group.
/// </summary>
public string Location
{
get { return location; }
set { this.location = value; }
}
public AbstractQueueMemberEvent(ManagerConnection source) /// <summary>
: base(source) /// Returns the name of the member's interface.<br />
{ } /// E.g. the channel name or agent group.
} /// </summary>
public string Location { get; set; }
}
} }

View file

@ -1,31 +1,22 @@
namespace AsterNET.Manager.Event namespace AsterNET.Manager.Event
{ {
/// <summary> /// <summary>
/// An AgentCallbackLoginEvent is triggered when an agent is successfully logged in using AgentCallbackLogin.<br/> /// An AgentCallbackLoginEvent is triggered when an agent is successfully logged in using AgentCallbackLogin.<br />
/// It is implemented in <code>channels/chan_agent.c</code> /// It is implemented in <code>channels/chan_agent.c</code>
/// </summary> /// </summary>
/// <seealso cref="Manager.event.AgentCallbackLogoffEvent" /> /// <seealso cref="Manager.event.AgentCallbackLogoffEvent" />
public class AgentCallbackLoginEvent : ManagerEvent public class AgentCallbackLoginEvent : ManagerEvent
{ {
private string agent; public AgentCallbackLoginEvent(ManagerConnection source)
private string loginChan; : base(source)
{
}
/// <summary> /// <summary>
/// Get/Set the name of the agent that logged in. /// Get/Set the name of the agent that logged in.
/// </summary> /// </summary>
public string Agent public string Agent { get; set; }
{
get { return agent; }
set { this.agent = value; }
}
public string LoginChan
{
get { return loginChan; }
set { this.loginChan = value; }
}
public AgentCallbackLoginEvent(ManagerConnection source) public string LoginChan { get; set; }
: base(source) }
{ }
}
} }

View file

@ -1,92 +1,48 @@
namespace AsterNET.Manager.Event namespace AsterNET.Manager.Event
{ {
/// <summary> /// <summary>
/// An AgentCallbackLogoffEvent is triggered when an agent that previously logged in using /// An AgentCallbackLogoffEvent is triggered when an agent that previously logged in using
/// AgentCallbackLogin is logged of.<br/> /// AgentCallbackLogin is logged of.<br />
/// It is implemented in <code>channels/chan_agent.c</code> /// It is implemented in <code>channels/chan_agent.c</code>
/// </summary> /// </summary>
/// <seealso cref="Manager.event.AgentCallbackLoginEvent" /> /// <seealso cref="Manager.event.AgentCallbackLoginEvent" />
public class AgentCallbackLogoffEvent : ManagerEvent public class AgentCallbackLogoffEvent : ManagerEvent
{ {
private string agent; #region Agent
private string loginChan;
private string loginTime;
private string reason;
#region Agent /// <summary> Returns the name of the agent that logged off.</summary>
/// <summary> Returns the name of the agent that logged off.</summary> /// <summary> Sets the name of the agent that logged off.</summary>
/// <summary> Sets the name of the agent that logged off.</summary> public string Agent { get; set; }
public string Agent
{
get
{
return agent;
}
set
{
this.agent = value;
}
} #endregion
#endregion
#region LoginChan #region LoginChan
public string LoginChan
{
get
{
return loginChan;
}
set
{
this.loginChan = value;
}
} public string LoginChan { get; set; }
#endregion
#region LoginTime #endregion
public string LoginTime
{
get
{
return loginTime;
}
set
{
this.loginTime = value;
}
} #region LoginTime
#endregion
#region Reason public string LoginTime { get; set; }
/// <summary>
/// Returns the reason for the logoff. The reason is set to Autologoff if the agent has been
/// logged off due to not answering the phone in time. Autologoff is configured by setting
/// <code>autologoff</code> to the appropriate number of seconds in <code>agents.conf</code>.
/// </summary>
/// <summary>Sets the reason for the logoff.</summary>
public string Reason
{
get
{
return reason;
}
set
{
this.reason = value;
}
} #endregion
#endregion
public AgentCallbackLogoffEvent(ManagerConnection source) #region Reason
: base(source)
{ } /// <summary>
} /// Returns the reason for the logoff. The reason is set to Autologoff if the agent has been
/// logged off due to not answering the phone in time. Autologoff is configured by setting
/// <code>autologoff</code> to the appropriate number of seconds in <code>agents.conf</code>.
/// </summary>
/// <summary>Sets the reason for the logoff.</summary>
public string Reason { get; set; }
#endregion
public AgentCallbackLogoffEvent(ManagerConnection source)
: base(source)
{
}
}
} }

View file

@ -1,89 +1,43 @@
using System.Collections;
namespace AsterNET.Manager.Event namespace AsterNET.Manager.Event
{ {
/// <summary> /// <summary>
/// An AgentCalledEvent is triggered when an agent is rung.<br/> /// An AgentCalledEvent is triggered when an agent is rung.<br />
/// To enable AgentCalledEvents you have to set <code>eventwhencalled = yes</code> in <code>queues.conf</code>.<br/> /// To enable AgentCalledEvents you have to set <code>eventwhencalled = yes</code> in <code>queues.conf</code>.<br />
/// This event is implemented in <code>apps/app_queue.c</code> /// This event is implemented in <code>apps/app_queue.c</code>
/// </summary> /// </summary>
public class AgentCalledEvent : AbstractAgentVariables public class AgentCalledEvent : AbstractAgentVariables
{ {
private string agentCalled; public AgentCalledEvent(ManagerConnection source)
private string agentName; : base(source)
private string callerId; {
private string callerIdName; }
private string callerIdNum;
private string channelCalling;
private string context;
private string destinationChannel;
private string extension;
private string priority;
private string queue;
public string Queue public string Queue { get; set; }
{
get { return this.queue; } public string AgentName { get; set; }
set { this.queue = value; }
} public string AgentCalled { get; set; }
public string AgentName
{ public string ChannelCalling { get; set; }
get { return agentName; }
set { this.agentName = value; } public string DestinationChannel { get; set; }
}
public string AgentCalled public string CallerId { get; set; }
{
get { return agentCalled; } /// <summary>
set { this.agentCalled = value; } /// Get/Set the Caller*ID number of the calling channel.
} /// </summary>
public string ChannelCalling public string CallerIdNum { get; set; }
{
get { return channelCalling; } /// <summary>
set { this.channelCalling = value; } /// Get/Set the Caller*ID name of the calling channel.
} /// </summary>
public string DestinationChannel public string CallerIdName { get; set; }
{
get { return this.destinationChannel; } public string Context { get; set; }
set { this.destinationChannel = value; }
} public string Extension { get; set; }
public string CallerId
{ public string Priority { get; set; }
get { return callerId; } }
set { this.callerId = value; }
}
/// <summary>
/// Get/Set the Caller*ID number of the calling channel.
/// </summary>
public string CallerIdNum
{
get { return callerIdNum; }
set { this.callerIdNum = value; }
}
/// <summary>
/// Get/Set the Caller*ID name of the calling channel.
/// </summary>
public string CallerIdName
{
get { return callerIdName; }
set { this.callerIdName = value; }
}
public string Context
{
get { return context; }
set { this.context = value; }
}
public string Extension
{
get { return extension; }
set { this.extension = value; }
}
public string Priority
{
get { return priority; }
set { this.priority = value; }
}
public AgentCalledEvent(ManagerConnection source)
: base(source)
{ }
}
} }

View file

@ -1,41 +1,28 @@
namespace AsterNET.Manager.Event namespace AsterNET.Manager.Event
{ {
/// <summary> /// <summary>
/// An AgentCompleteEvent is triggered when at the end of a call if the caller was connected to an agent. /// An AgentCompleteEvent is triggered when at the end of a call if the caller was connected to an agent.
/// </summary> /// </summary>
public class AgentCompleteEvent : AbstractAgentEvent public class AgentCompleteEvent : AbstractAgentEvent
{ {
private long holdTime; public AgentCompleteEvent(ManagerConnection source)
private string reason; : base(source)
private long talkTime; {
}
/// <summary> /// <summary>
/// Get/Set the amount of time the caller was on hold. /// Get/Set the amount of time the caller was on hold.
/// </summary> /// </summary>
public long HoldTime public long HoldTime { get; set; }
{
get { return holdTime; } /// <summary>
set { this.holdTime = value; } /// Get/Set the amount of time the caller talked to the agent.
} /// </summary>
/// <summary> public long TalkTime { get; set; }
/// Get/Set the amount of time the caller talked to the agent.
/// </summary> /// <summary>
public long TalkTime /// Get/Set if the agent or the caller terminated the call.
{ /// </summary>
get { return talkTime; } public string Reason { get; set; }
set { this.talkTime = value; } }
}
/// <summary>
/// Get/Set if the agent or the caller terminated the call.
/// </summary>
public string Reason
{
get { return reason; }
set { this.reason = value; }
}
public AgentCompleteEvent(ManagerConnection source)
: base(source)
{ }
}
} }

View file

@ -1,44 +1,28 @@
namespace AsterNET.Manager.Event namespace AsterNET.Manager.Event
{ {
/// <summary> /// <summary>
/// An AgentConnectEvent is triggered when a caller is connected to an agent. /// An AgentConnectEvent is triggered when a caller is connected to an agent.
/// </summary> /// </summary>
public class AgentConnectEvent : AbstractAgentEvent public class AgentConnectEvent : AbstractAgentEvent
{ {
private string bridgedChannel; public AgentConnectEvent(ManagerConnection source)
private long holdTime; : base(source)
private long ringTime; {
}
/// <summary> /// <summary>
/// Get/Set the amount of time the caller was on hold. /// Get/Set the amount of time the caller was on hold.
/// </summary> /// </summary>
public long HoldTime public long HoldTime { get; set; }
{
get { return holdTime; }
set { this.holdTime = value; }
}
/// <summary> /// <summary>
/// Get/Set bridged channel. /// Get/Set bridged channel.
/// </summary> /// </summary>
public string BridgedChannel public string BridgedChannel { get; set; }
{
get { return this.bridgedChannel; }
set { this.bridgedChannel = value; }
}
/// <summary> /// <summary>
/// Get/Set the amount of time the caller was on ring. /// Get/Set the amount of time the caller was on ring.
/// </summary> /// </summary>
public long RingTime public long RingTime { get; set; }
{ }
get { return ringTime; }
set { this.ringTime = value; }
}
public AgentConnectEvent(ManagerConnection source)
: base(source)
{
}
}
} }

View file

@ -1,32 +1,22 @@
namespace AsterNET.Manager.Event namespace AsterNET.Manager.Event
{ {
/// <summary> /// <summary>
/// An AgentLoginEvent is triggered when an agent is successfully logged in using AgentLogin.<br/> /// An AgentLoginEvent is triggered when an agent is successfully logged in using AgentLogin.<br />
/// It is implemented in <code>channels/chan_agent.c</code> /// It is implemented in <code>channels/chan_agent.c</code>
/// </summary> /// </summary>
/// <seealso cref="Manager.event.AgentLogoffEvent" /> /// <seealso cref="Manager.event.AgentLogoffEvent" />
public class AgentLoginEvent : ManagerEvent public class AgentLoginEvent : ManagerEvent
{ {
private string agent; public AgentLoginEvent(ManagerConnection source)
private string loginChan; : base(source)
{
}
/// <summary> /// <summary>
/// Get/Set the name of the agent that logged in. /// Get/Set the name of the agent that logged in.
/// </summary> /// </summary>
public string Agent public string Agent { get; set; }
{
get { return agent; }
set { this.agent = value; }
}
public string LoginChan
{
get { return loginChan; }
set { this.loginChan = value; }
}
public AgentLoginEvent(ManagerConnection source) public string LoginChan { get; set; }
: base(source) }
{
}
}
} }

View file

@ -1,32 +1,23 @@
namespace AsterNET.Manager.Event namespace AsterNET.Manager.Event
{ {
/// <summary> /// <summary>
/// An AgentCallbackLogoffEvent is triggered when an agent that previously logged in using AgentLogin is logged of.<br/> /// An AgentCallbackLogoffEvent is triggered when an agent that previously logged in using AgentLogin is logged of.
/// It is implemented in <code>channels/chan_agent.c</code> /// <br />
/// </summary> /// It is implemented in <code>channels/chan_agent.c</code>
/// <seealso cref="Manager.event.AgentLoginEvent" /> /// </summary>
public class AgentLogoffEvent : ManagerEvent /// <seealso cref="Manager.event.AgentLoginEvent" />
{ public class AgentLogoffEvent : ManagerEvent
private string agent; {
private string loginTime; public AgentLogoffEvent(ManagerConnection source)
: base(source)
/// <summary> {
/// Get/Set the name of the agent that logged off. }
/// </summary>
public string Agent /// <summary>
{ /// Get/Set the name of the agent that logged off.
get { return agent; } /// </summary>
set { this.agent = value; } public string Agent { get; set; }
}
public string LoginTime public string LoginTime { get; set; }
{ }
get { return loginTime; }
set { this.loginTime = value; }
}
public AgentLogoffEvent(ManagerConnection source)
: base(source)
{
}
}
} }

View file

@ -1,82 +1,56 @@
namespace AsterNET.Manager.Event namespace AsterNET.Manager.Event
{ {
/// <summary> /// <summary>
/// An AgentsEvent is triggered for each agent in response to an AgentsAction.<br/> /// An AgentsEvent is triggered for each agent in response to an AgentsAction.<br />
/// Available since Asterisk 1.2 /// Available since Asterisk 1.2
/// </summary> /// </summary>
/// <seealso cref="Manager.Action.AgentsAction" /> /// <seealso cref="Manager.Action.AgentsAction" />
public class AgentsEvent : ResponseEvent public class AgentsEvent : ResponseEvent
{ {
private string agent; public AgentsEvent(ManagerConnection source)
private string name; : base(source)
private string status; {
private string loggedInChan; }
private string talkingTo;
private long loggedInTime;
/// <summary> /// <summary>
/// Get/Set the agentid. /// Get/Set the agentid.
/// </summary> /// </summary>
public string Agent public string Agent { get; set; }
{
get { return this.agent; }
set { this.agent = value; }
}
/// <summary>
/// Get/Set the name of this agent.
/// </summary>
public string Name
{
get { return this.name; }
set { this.name = value; }
}
/// <summary>
/// Get/Set the status of this agent.<br/>
/// This is one of
/// <dl>
/// <dt>"AGENT_LOGGEDOFF"</dt>
/// <dd>Agent isn't logged in</dd>
/// <dt>"AGENT_IDLE"</dt>
/// <dd>Agent is logged in, and waiting for call</dd>
/// <dt>"AGENT_ONCALL"</dt>
/// <dd>Agent is logged in, and on a call</dd>
/// <dt>"AGENT_UNKNOWN"</dt>
/// <dd>Don't know anything about agent. Shouldn't ever get this.</dd>
/// </dl>
/// </summary>
public string Status
{
get { return this.status; }
set { this.status = value; }
}
/// <summary>
/// Get/Set the name of channel this agent logged in from or "n/a" if the agent is not logged in.
/// </summary>
public string LoggedInChan
{
get { return this.loggedInChan; }
set { this.loggedInChan = value; }
}
/// <summary>
/// Get/Set the time (in seconds since 01/01/1970) when the agent logged in or 0 if the user is not logged.
/// </summary>
public long LoggedInTime
{
get { return this.loggedInTime; }
set { this.loggedInTime = value; }
}
/// <summary>
/// Get/Set the numerical Caller*ID of the channel this agent is talking toor "n/a" if this agent is talking to nobody.
/// </summary>
public string TalkingTo
{
get { return this.talkingTo; }
set { this.talkingTo = value; }
}
public AgentsEvent(ManagerConnection source) /// <summary>
: base(source) /// Get/Set the name of this agent.
{ /// </summary>
} public string Name { get; set; }
}
/// <summary>
/// Get/Set the status of this agent.<br />
/// This is one of
/// <dl>
/// <dt>"AGENT_LOGGEDOFF"</dt>
/// <dd>Agent isn't logged in</dd>
/// <dt>"AGENT_IDLE"</dt>
/// <dd>Agent is logged in, and waiting for call</dd>
/// <dt>"AGENT_ONCALL"</dt>
/// <dd>Agent is logged in, and on a call</dd>
/// <dt>"AGENT_UNKNOWN"</dt>
/// <dd>Don't know anything about agent. Shouldn't ever get this.</dd>
/// </dl>
/// </summary>
public string Status { get; set; }
/// <summary>
/// Get/Set the name of channel this agent logged in from or "n/a" if the agent is not logged in.
/// </summary>
public string LoggedInChan { get; set; }
/// <summary>
/// Get/Set the time (in seconds since 01/01/1970) when the agent logged in or 0 if the user is not logged.
/// </summary>
public long LoggedInTime { get; set; }
/// <summary>
/// Get/Set the numerical Caller*ID of the channel this agent is talking toor "n/a" if this agent is talking to nobody.
/// </summary>
public string TalkingTo { get; set; }
}
} }

View file

@ -1,34 +1,28 @@
namespace AsterNET.Manager.Event namespace AsterNET.Manager.Event
{ {
/// <summary> /// <summary>
/// An AlarmEvent is triggered when a Zap channel enters or changes alarm state.<br/> /// An AlarmEvent is triggered when a Zap channel enters or changes alarm state.<br />
/// It is implemented in <code>channels/chan_zap.c</code> /// It is implemented in <code>channels/chan_zap.c</code>
/// </summary> /// </summary>
public class AlarmEvent : ManagerEvent public class AlarmEvent : ManagerEvent
{ {
private string alarm; public AlarmEvent(ManagerConnection source)
: base(source)
{
}
/// <summary> /// <summary>
/// Get/Set the kind of alarm that happened.<br/> /// Get/Set the kind of alarm that happened.<br />
/// This may be one of /// This may be one of
/// <ul> /// <ul>
/// <li>Red Alarm</li> /// <li>Red Alarm</li>
/// <li>Yellow Alarm</li> /// <li>Yellow Alarm</li>
/// <li>Blue Alarm</li> /// <li>Blue Alarm</li>
/// <li>Recovering</li> /// <li>Recovering</li>
/// <li>Loopback</li> /// <li>Loopback</li>
/// <li>Not Open</li> /// <li>Not Open</li>
/// </ul> /// </ul>
/// </summary> /// </summary>
public string Alarm public string Alarm { get; set; }
{ }
get { return alarm; }
set { this.alarm = value; }
}
public AlarmEvent(ManagerConnection source)
: base(source)
{
}
}
} }

View file

@ -1,40 +1,22 @@
using System;
namespace AsterNET.Manager.Event namespace AsterNET.Manager.Event
{ {
public class AsyncAGIEvent : ManagerEvent public class AsyncAGIEvent : ManagerEvent
{ {
private string subEvent; public string Result { get; set; }
private string env;
private string result;
private string commandId;
public string Result public string CommandId { get; set; }
{
get { return result; }
set { result = value; }
}
public string CommandId
{
get { return commandId; }
set { commandId = value; }
}
public string SubEvent
{
get { return subEvent; }
set { subEvent = value; }
}
public string Env
{
get { return env; }
set { env = value; }
}
#region Constructor - AsyncAGIEvent(ManagerConnection source) public string SubEvent { get; set; }
public AsyncAGIEvent(ManagerConnection source)
: base(source) public string Env { get; set; }
{
} #region Constructor - AsyncAGIEvent(ManagerConnection source)
#endregion
} public AsyncAGIEvent(ManagerConnection source)
} : base(source)
{
}
#endregion
}
}

View file

@ -1,114 +1,48 @@
namespace AsterNET.Manager.Event namespace AsterNET.Manager.Event
{ {
/// <summary> /// <summary>
/// A CdrEvent is triggered when a call detail record is generated, usually at the end of a call.<br/> /// A CdrEvent is triggered when a call detail record is generated, usually at the end of a call.<br />
/// To enable CdrEvents you have to add <code>enabled = yes</code> to the general section in /// To enable CdrEvents you have to add <code>enabled = yes</code> to the general section in
/// <code>cdr_manager.conf</code>.<br/> /// <code>cdr_manager.conf</code>.<br />
/// This event is implemented in <code>cdr/cdr_manager.c</code> /// This event is implemented in <code>cdr/cdr_manager.c</code>
/// </summary> /// </summary>
public class CdrEvent : ManagerEvent public class CdrEvent : ManagerEvent
{ {
private string accountCode; public CdrEvent(ManagerConnection source)
private string src; : base(source)
private string destination; {
private string destinationContext; }
private string callerId;
private string destinationChannel;
private string lastApplication;
private string lastData;
private string startTime;
private string answerTime;
private string endTime;
private long duration;
private long billableSeconds;
private string disposition;
private string amaFlags;
private string userField;
public CdrEvent(ManagerConnection source) public string AccountCode { get; set; }
: base(source)
{
}
public string AccountCode public string Src { get; set; }
{
get { return accountCode; } public string Destination { get; set; }
set { this.accountCode = value; }
} public string DestinationContext { get; set; }
public string Src
{ public string CallerId { get; set; }
get { return src; }
set { this.src = value; } public string DestinationChannel { get; set; }
}
public string Destination public string LastApplication { get; set; }
{
get { return destination; } public string LastData { get; set; }
set { this.destination = value; }
} public string StartTime { get; set; }
public string DestinationContext
{ public string AnswerTime { get; set; }
get { return destinationContext; }
set { this.destinationContext = value; } public string EndTime { get; set; }
}
public string CallerId public long Duration { get; set; }
{
get { return callerId; } public long BillableSeconds { get; set; }
set { this.callerId = value; }
} public string Disposition { get; set; }
public string DestinationChannel
{ public string AmaFlags { get; set; }
get { return destinationChannel; }
set { this.destinationChannel = value; } public string UserField { get; set; }
} }
public string LastApplication
{
get { return lastApplication; }
set { this.lastApplication = value; }
}
public string LastData
{
get { return lastData; }
set { this.lastData = value; }
}
public string StartTime
{
get { return startTime; }
set { this.startTime = value; }
}
public string AnswerTime
{
get { return answerTime; }
set { this.answerTime = value; }
}
public string EndTime
{
get { return endTime; }
set { this.endTime = value; }
}
public long Duration
{
get { return duration; }
set { this.duration = value; }
}
public long BillableSeconds
{
get { return billableSeconds; }
set { this.billableSeconds = value; }
}
public string Disposition
{
get { return disposition; }
set { this.disposition = value; }
}
public string AmaFlags
{
get { return amaFlags; }
set { this.amaFlags = value; }
}
public string UserField
{
get { return userField; }
set { this.userField = value; }
}
}
} }

Some files were not shown because too many files have changed in this diff Show more