diff --git a/Asterisk.2013/Asterisk.NET.Test/Asterisk.NET.Test/Program.cs b/Asterisk.2013/Asterisk.NET.Test/Asterisk.NET.Test/Program.cs index 5d2eeeb..bec6da2 100644 --- a/Asterisk.2013/Asterisk.NET.Test/Asterisk.NET.Test/Program.cs +++ b/Asterisk.2013/Asterisk.NET.Test/Asterisk.NET.Test/Program.cs @@ -288,8 +288,8 @@ Ctrl-C to exit"); Console.WriteLine("Redirect Call from " + ORIGINATE_CHANNEL + " to " + ORIGINATE_EXTRA_CHANNEL + " or press ESC."); // Wait for Dial Event from ORIGINATE_CHANNEL - EventHandler de = dam_Dial; - manager.Dial += new EventHandler(de); + EventHandler de = new EventHandler(dam_Dial); + manager.Dial += de; while (transferChannel == null) { System.Threading.Thread.Sleep(100); @@ -324,7 +324,7 @@ Ctrl-C to exit"); Console.WriteLine("Monitor call. Please call " + ORIGINATE_CHANNEL + " and answer or press ESC."); // Wait for Link event EventHandler le = new EventHandler(dam_Link); - manager.Link += new EventHandler(le); + manager.Link += le; while (monitorChannel == null) { System.Threading.Thread.Sleep(100); diff --git a/Asterisk.2013/Asterisk.NET/AsterNET.csproj b/Asterisk.2013/Asterisk.NET/AsterNET.csproj index 7301a75..7efe675 100644 --- a/Asterisk.2013/Asterisk.NET/AsterNET.csproj +++ b/Asterisk.2013/Asterisk.NET/AsterNET.csproj @@ -167,6 +167,7 @@ + @@ -195,6 +196,7 @@ + @@ -256,6 +258,7 @@ + @@ -323,6 +326,11 @@ + + + + + diff --git a/Asterisk.2013/Asterisk.NET/FastAGI/AsteriskFastAGI.cs b/Asterisk.2013/Asterisk.NET/FastAGI/AsteriskFastAGI.cs index 8e7decf..c200a7c 100644 --- a/Asterisk.2013/Asterisk.NET/FastAGI/AsteriskFastAGI.cs +++ b/Asterisk.2013/Asterisk.NET/FastAGI/AsteriskFastAGI.cs @@ -1,3 +1,4 @@ +using System; using System.IO; using System.Net; using System.Text; @@ -233,13 +234,29 @@ namespace AsterNET.FastAGI var ipAddress = IPAddress.Parse(address); serverSocket = new ServerSocket(port, ipAddress, SocketEncoding); } - catch (IOException ex) + catch (Exception ex) { #if LOGGER - logger.Error("Unable start AGI Server: cannot to bind to " + address + ":" + port + ".", ex); + if (ex is IOException) + { + logger.Error("Unable start AGI Server: cannot to bind to " + address + ":" + port + ".", ex); + } #endif + + if (serverSocket != null) + { + serverSocket.Close(); + serverSocket = null; + } + + pool.Shutdown(); +#if LOGGER + logger.Info("AGI Server shut down."); +#endif + throw ex; } + #if LOGGER logger.Info("Listening on " + address + ":" + port + "."); #endif @@ -287,7 +304,7 @@ namespace AsterNET.FastAGI serverSocket = null; pool.Shutdown(); #if LOGGER - logger.Info("AGIServer shut down."); + logger.Info("AGI Server shut down."); #endif } } diff --git a/Asterisk.2013/Asterisk.NET/FastAGI/MappingStrategies/GeneralMappingStrategy.cs b/Asterisk.2013/Asterisk.NET/FastAGI/MappingStrategies/GeneralMappingStrategy.cs index 344fc94..b149ebd 100644 --- a/Asterisk.2013/Asterisk.NET/FastAGI/MappingStrategies/GeneralMappingStrategy.cs +++ b/Asterisk.2013/Asterisk.NET/FastAGI/MappingStrategies/GeneralMappingStrategy.cs @@ -47,6 +47,7 @@ namespace AsterNET.FastAGI.MappingStrategies /// public string ScriptAssmebly { get; set; } + [XmlIgnoreAttribute] public Assembly PreLoadedAssembly { get; set; } public static List LoadMappings(string pathToXml) @@ -184,4 +185,4 @@ namespace AsterNET.FastAGI.MappingStrategies } } -} \ No newline at end of file +} diff --git a/Asterisk.2013/Asterisk.NET/Helper.cs b/Asterisk.2013/Asterisk.NET/Helper.cs index 49bb485..e6fc507 100644 --- a/Asterisk.2013/Asterisk.NET/Helper.cs +++ b/Asterisk.2013/Asterisk.NET/Helper.cs @@ -872,7 +872,7 @@ namespace AsterNET #endregion - #region RegisterEventHandler(Dictionary> list, Type eventType, Action action) + #region RegisterEventHandler(Dictionary list, int index, Type eventType) internal static void RegisterEventHandler(Dictionary> list, Type eventType, Func action) { diff --git a/Asterisk.2013/Asterisk.NET/IO/SocketConnection.cs b/Asterisk.2013/Asterisk.NET/IO/SocketConnection.cs index 07145ae..5df2484 100644 --- a/Asterisk.2013/Asterisk.NET/IO/SocketConnection.cs +++ b/Asterisk.2013/Asterisk.NET/IO/SocketConnection.cs @@ -11,7 +11,7 @@ namespace AsterNET.IO private TcpClient tcpClient; private NetworkStream networkStream; private StreamReader reader; - private StreamWriter writer; + private BinaryWriter writer; private Encoding encoding; private bool initial; @@ -29,8 +29,7 @@ namespace AsterNET.IO this.tcpClient = new TcpClient(host, port); this.networkStream = this.tcpClient.GetStream(); this.reader = new StreamReader(this.networkStream, encoding); - this.writer = new StreamWriter(this.networkStream, encoding); - this.writer.AutoFlush = true; + this.writer = new BinaryWriter(this.networkStream, encoding); } #endregion @@ -47,8 +46,7 @@ namespace AsterNET.IO this.tcpClient = tcpClient; this.networkStream = this.tcpClient.GetStream(); this.reader = new StreamReader(this.networkStream, encoding); - this.writer = new StreamWriter(this.networkStream, encoding); - this.writer.AutoFlush = true; + this.writer = new BinaryWriter(this.networkStream, encoding); } #endregion @@ -156,7 +154,8 @@ namespace AsterNET.IO /// connection has already been closed. public void Write(string s) { - writer.Write(s); + writer.Write(encoding.GetBytes(s)); + writer.Flush(); } #endregion diff --git a/Asterisk.2013/Asterisk.NET/Manager/Action/FilterAction.cs b/Asterisk.2013/Asterisk.NET/Manager/Action/FilterAction.cs new file mode 100644 index 0000000..765f99b --- /dev/null +++ b/Asterisk.2013/Asterisk.NET/Manager/Action/FilterAction.cs @@ -0,0 +1,55 @@ +namespace AsterNET.Manager.Action +{ + /// + /// Dynamically add filters for the current manager session + /// The filters added are only used for the current session. Once the connection is closed the filters are removed. + /// This comand requires the system permission because this command can be used to create filters that may bypass filters defined in manager.conf + /// + public class FilterAction : ManagerAction + { + #region Action + + /// + /// Get the name of this action, i.e. "Filter". + /// + public override string Action + { + get { return "Filter"; } + } + + #endregion + + #region Operation + + /// + /// Add - Add a filter + /// + public string Operation { get; set; } + + #endregion + + #region Filter + + /// + /// Filters can be whitelist or blacklist + /// Example whitelist filter: "Event: Newchannel" + /// Example blacklist filter: "!Channel: DAHDI.*" + /// + public string Filter { get; set; } + + #endregion + + #region FilterAction(string filter) + + /// + /// Add - Add a filter + /// + /// + public FilterAction(string filter) + { + Filter = filter; + } + + #endregion + } +} diff --git a/Asterisk.2013/Asterisk.NET/Manager/Action/OriginateAction.cs b/Asterisk.2013/Asterisk.NET/Manager/Action/OriginateAction.cs index a57e46d..0dd5469 100644 --- a/Asterisk.2013/Asterisk.NET/Manager/Action/OriginateAction.cs +++ b/Asterisk.2013/Asterisk.NET/Manager/Action/OriginateAction.cs @@ -159,7 +159,7 @@ namespace AsterNET.Manager.Action /// Example: "VAR1=abc|VAR2=def" sets the channel variables VAR1 to "abc" and VAR2 to "def". /// - [Obsolete("Don't use this anymore - the delimiter is not server context aware", true)] + [Obsolete("Use GetVariables and SetVariables instead.", true)] public string Variable { get { return null; /* return Helper.JoinVariables(variables, Common.GET_VAR_DELIMITER(this.Server), "="); */ } diff --git a/Asterisk.2013/Asterisk.NET/Manager/Action/QueueSummaryAction.cs b/Asterisk.2013/Asterisk.NET/Manager/Action/QueueSummaryAction.cs new file mode 100644 index 0000000..703daae --- /dev/null +++ b/Asterisk.2013/Asterisk.NET/Manager/Action/QueueSummaryAction.cs @@ -0,0 +1,51 @@ +using AsterNET.Manager.Event; +using System; + +namespace AsterNET.Manager.Action +{ + /// + /// Show queue summary + /// + /// + public class QueueSummaryAction : ManagerActionEvent + { + #region Action + + /// + /// Get the name of this action, i.e. "Filter". + /// + public override string Action + { + get { return "QueueSummary"; } + } + + #endregion + + #region MyRegion + + /// + /// Name of queue + /// + public string Queue { get; set; } + + #endregion + + #region QueueSummaryAction(string queue) + + public QueueSummaryAction(string queue) + { + Queue = queue; + } + + #endregion + + #region ActionCompleteEventClass() + + public override Type ActionCompleteEventClass() + { + return typeof(QueueSummaryEvent); + } + + #endregion + } +} diff --git a/Asterisk.2013/Asterisk.NET/Manager/Event/AbstractAgentVariables.cs b/Asterisk.2013/Asterisk.NET/Manager/Event/AbstractAgentVariables.cs index 365dc2a..bd87013 100644 --- a/Asterisk.2013/Asterisk.NET/Manager/Event/AbstractAgentVariables.cs +++ b/Asterisk.2013/Asterisk.NET/Manager/Event/AbstractAgentVariables.cs @@ -18,26 +18,26 @@ namespace AsterNET.Manager.Event /// Get/Set the variables to set on the queue call in native asterisk format.
/// Example: "VAR1=abc|VAR2=def". /// - [Obsolete("Don't use this anymore - the delimiter is not server context aware", true)] - public string Variable - { - get { return null; /* return Helper.JoinVariables(variables, Common.GET_VAR_DELIMITER(this.Server), "="); */ } - set { /* variables = Helper.ParseVariables(variables, value, Common.GET_VAR_DELIMITER(this.Server)); */ } - } + [Obsolete("Use GetVariables and SetVariables instead.", true)] + public string Variable + { + get { return null; /* return Helper.JoinVariables(variables, Common.GET_VAR_DELIMITER(this.Server), "="); */ } + set { /* variables = Helper.ParseVariables(variables, value, Common.GET_VAR_DELIMITER(this.Server)); */ } + } #endregion #region GetVariables() /// /// Get the variables dictionary to set on the originated call. /// - public Dictionary GetVariables() + public Dictionary GetVariables() { return variables; } #endregion - #region SetVariables(Dictionary vars) - /// + #region SetVariables(Dictionary vars) + /// /// Set the variables dictionary to set on the originated call. /// public void SetVariables(Dictionary vars) diff --git a/Asterisk.2013/Asterisk.NET/Manager/Event/ChallengeResponseFailedEvent.cs b/Asterisk.2013/Asterisk.NET/Manager/Event/ChallengeResponseFailedEvent.cs new file mode 100644 index 0000000..170b5cb --- /dev/null +++ b/Asterisk.2013/Asterisk.NET/Manager/Event/ChallengeResponseFailedEvent.cs @@ -0,0 +1,16 @@ +namespace AsterNET.Manager.Event +{ + + /// + /// Raised when a request's attempt to authenticate has been challenged, and the request failed the authentication challenge.
+ ///
+ public class ChallengeResponseFailedEvent : ManagerEvent +{ + public ChallengeResponseFailedEvent(ManagerConnection source) + : base(source) + { + } + + public string Status { get; set; } + } +} diff --git a/Asterisk.2013/Asterisk.NET/Manager/Event/ChallengeSentEvent.cs b/Asterisk.2013/Asterisk.NET/Manager/Event/ChallengeSentEvent.cs new file mode 100644 index 0000000..3107bbe --- /dev/null +++ b/Asterisk.2013/Asterisk.NET/Manager/Event/ChallengeSentEvent.cs @@ -0,0 +1,16 @@ +namespace AsterNET.Manager.Event +{ + + /// + /// Raised when an Asterisk service sends an authentication challenge to a request..
+ ///
+ public class ChallengeSentEvent : ManagerEvent + { + public ChallengeSentEvent(ManagerConnection source) + : base(source) + { + } + + public string Status { get; set; } + } +} \ No newline at end of file diff --git a/Asterisk.2013/Asterisk.NET/Manager/Event/DeviceStateChangeEvent.cs b/Asterisk.2013/Asterisk.NET/Manager/Event/DeviceStateChangeEvent.cs new file mode 100644 index 0000000..3ffb3df --- /dev/null +++ b/Asterisk.2013/Asterisk.NET/Manager/Event/DeviceStateChangeEvent.cs @@ -0,0 +1,17 @@ +namespace AsterNET.Manager.Event +{ + + /// + /// Raised when a device state changes.
+ /// This differs from the ExtensionStatus event because this event is raised for all device state changes, not only for changes that affect dialplan hints. + ///
+ public class DeviceStateChangeEvent : ManagerEvent + { + public DeviceStateChangeEvent(ManagerConnection source) + : base(source) + { + } + + public string Status { get; set; } + } +} \ No newline at end of file diff --git a/Asterisk.2013/Asterisk.NET/Manager/Event/InvalidAccountIDEvent.cs b/Asterisk.2013/Asterisk.NET/Manager/Event/InvalidAccountIDEvent.cs new file mode 100644 index 0000000..9971054 --- /dev/null +++ b/Asterisk.2013/Asterisk.NET/Manager/Event/InvalidAccountIDEvent.cs @@ -0,0 +1,16 @@ +namespace AsterNET.Manager.Event +{ + + /// + /// Raised when a request fails an authentication check due to an invalid account ID.
+ ///
+ public class InvalidAccountIDEvent : ManagerEvent + { + public InvalidAccountIDEvent(ManagerConnection source) + : base(source) + { + } + + public string Status { get; set; } + } +} \ No newline at end of file diff --git a/Asterisk.2013/Asterisk.NET/Manager/Event/QueueCallerJoinEvent.cs b/Asterisk.2013/Asterisk.NET/Manager/Event/QueueCallerJoinEvent.cs index 0416417..78e7c65 100644 --- a/Asterisk.2013/Asterisk.NET/Manager/Event/QueueCallerJoinEvent.cs +++ b/Asterisk.2013/Asterisk.NET/Manager/Event/QueueCallerJoinEvent.cs @@ -1,15 +1,23 @@ namespace AsterNET.Manager.Event { - /// - /// A QueueCallerJoinEvent is triggered when a channel joins a queue.
- ///
- public class QueueCallerJoinEvent : QueueEvent - { - public string Position { get; set; } - - public QueueCallerJoinEvent(ManagerConnection source) + /// + /// A QueueCallerJoinEvent is triggered when a channel joins a queue.
+ ///
+ public class QueueCallerJoinEvent : JoinEvent + { + // "Channel" in ManagerEvent.cs + + // "Queue" in QueueEvent.cs + + // "CallerId" in JoinEvent.cs + + // "CallerIdName" in JoinEvent.cs + + // "Position" in JoinEvent.cs + + public QueueCallerJoinEvent(ManagerConnection source) : base(source) { } } -} \ No newline at end of file +} diff --git a/Asterisk.2013/Asterisk.NET/Manager/Event/QueueCallerLeaveEvent.cs b/Asterisk.2013/Asterisk.NET/Manager/Event/QueueCallerLeaveEvent.cs index dff535a..86fc7b8 100644 --- a/Asterisk.2013/Asterisk.NET/Manager/Event/QueueCallerLeaveEvent.cs +++ b/Asterisk.2013/Asterisk.NET/Manager/Event/QueueCallerLeaveEvent.cs @@ -1,15 +1,19 @@ namespace AsterNET.Manager.Event { - /// - /// A QueueCallerLeaveEvent is triggered when a channel leaves a queue.
- ///
- public class QueueCallerLeaveEvent : QueueEvent - { - public string Position { get; set; } - - public QueueCallerLeaveEvent(ManagerConnection source) + /// + /// A QueueCallerLeaveEvent is triggered when a channel leaves a queue.
+ ///
+ public class QueueCallerLeaveEvent : LeaveEvent + { + // "Channel" in ManagerEvent.cs + + // "Queue" in QueueEvent.cs + + // "Count" in QueueEvent.cs + + public QueueCallerLeaveEvent(ManagerConnection source) : base(source) { } } -} \ No newline at end of file +} diff --git a/Asterisk.2013/Asterisk.NET/Manager/Event/QueueMemberAddedEvent.cs b/Asterisk.2013/Asterisk.NET/Manager/Event/QueueMemberAddedEvent.cs index 0bd5cd9..4ee20fa 100644 --- a/Asterisk.2013/Asterisk.NET/Manager/Event/QueueMemberAddedEvent.cs +++ b/Asterisk.2013/Asterisk.NET/Manager/Event/QueueMemberAddedEvent.cs @@ -1,73 +1,21 @@ namespace AsterNET.Manager.Event { - /// - /// A QueueMemberAddedEvent is triggered when a queue member is added to a queue.
- /// It is implemented in apps/app_queue.c.
- /// - /// Available since : Asterisk 1.2.
- ///
- ///
- public class QueueMemberAddedEvent : AbstractQueueMemberEvent + /// + /// A QueueMemberAddedEvent is triggered when a queue member is added to a queue.
+ /// It is implemented in apps/app_queue.c.
+ /// + /// Available since : Asterisk 1.2.
+ ///
+ ///
+ public class QueueMemberAddedEvent : AbstractQueueMemberEvent { /// - /// Returns the name of the member's interface.
- /// E.g. the channel name or agent group. + /// Creates a new QueueMemberAddedEvent ///
- public new string MemberName { get; set; } - - /// - /// Get/Set if the added member is a dynamic or static queue member. - /// "dynamic" if the added member is a dynamic queue member, - /// "static" if the added member is a static queue member. - /// - public new string Membership { get; set; } - - /// - /// Get/Set the penalty for the added member. When calls are distributed - /// members with higher penalties are considered last. - /// - public new int Penalty { get; set; } - - /// - /// Get/Set the number of calls answered by the member. - /// - public new int CallsTaken { get; set; } - - /// - /// Get/Set the time (in seconds since 01/01/1970) the last successful call answered by the added member was hungup. - /// - public new long LastCall { get; set; } - - /// - /// Get/Set the status of this queue member.
- /// Valid status codes are:
- /// - /// AST_DEVICE_UNKNOWN - /// AST_DEVICE_NOT_INUSE - /// AST_DEVICE_INUSE - /// AST_DEVICE_BUSY - /// AST_DEVICE_INVALID - /// AST_DEVICE_UNAVAILABLE - /// AST_DEVICE_RINGING - /// AST_DEVICE_RINGINUSE - /// AST_DEVICE_ONHOLD - /// - ///
- public new int Status { get; set; } - - /// - /// Get/Set value if this queue member is paused (not accepting calls).
- /// true if this member has been paused or false if not. - ///
- public new bool Paused { get; set; } - - /// - /// Creates a new QueueMemberAddedEvent - /// - /// ManagerConnection passed through in the event. - public QueueMemberAddedEvent(ManagerConnection source) + /// ManagerConnection passed through in the event. + public QueueMemberAddedEvent(ManagerConnection source) : base(source) { } } -} \ No newline at end of file +} diff --git a/Asterisk.2013/Asterisk.NET/Manager/Event/QueueMemberPausedEvent.cs b/Asterisk.2013/Asterisk.NET/Manager/Event/QueueMemberPausedEvent.cs index 6d00390..1aff4ba 100644 --- a/Asterisk.2013/Asterisk.NET/Manager/Event/QueueMemberPausedEvent.cs +++ b/Asterisk.2013/Asterisk.NET/Manager/Event/QueueMemberPausedEvent.cs @@ -2,39 +2,29 @@ using System; namespace AsterNET.Manager.Event { - /// - /// A QueueMemberPausedEvent is triggered when a queue member is paused or unpaused.
- /// It is implemented in apps/app_queue.c.
- /// - /// Available since : Asterisk 1.2.
- /// Replaced by : since Asterisk 12.
- /// Removed since : Asterisk 13.
- ///
- ///
+ /// + /// A QueueMemberPausedEvent is triggered when a queue member is paused or unpaused.
+ /// It is implemented in apps/app_queue.c.
+ /// + /// Available since : Asterisk 1.2.
+ /// Replaced by : since Asterisk 12.
+ /// Removed since : Asterisk 13.
+ ///
+ ///
public class QueueMemberPausedEvent : AbstractQueueMemberEvent { - /// - /// The reason a member was paused - /// - public string Reason { get; set; } - - /// - /// Not Available, use instead. - /// - public new string PausedReason { get; set; } - - /// - /// Not Available, use instead. - /// - public new bool InCall { get; set; } - - /// - /// Creates a new QueueMemberPausedEvent - /// - /// ManagerConnection passed through in the event. - public QueueMemberPausedEvent(ManagerConnection source) + /// + /// The reason a member was paused + /// + public string Reason { get; set; } + + /// + /// Creates a new QueueMemberPausedEvent + /// + /// ManagerConnection passed through in the event. + public QueueMemberPausedEvent(ManagerConnection source) : base(source) { - } + } } -} \ No newline at end of file +} diff --git a/Asterisk.2013/Asterisk.NET/Manager/Event/QueueMemberPenaltyEvent.cs b/Asterisk.2013/Asterisk.NET/Manager/Event/QueueMemberPenaltyEvent.cs index 417c46b..8918042 100644 --- a/Asterisk.2013/Asterisk.NET/Manager/Event/QueueMemberPenaltyEvent.cs +++ b/Asterisk.2013/Asterisk.NET/Manager/Event/QueueMemberPenaltyEvent.cs @@ -6,15 +6,10 @@ namespace AsterNET.Manager.Event public class QueueMemberPenaltyEvent : AbstractQueueMemberEvent { /// - /// Get/Set the penalty for the queue location. + /// Creates a new QueueMemberPenaltyEvent /// - public new int Penalty { get; set; } - - /// - /// Creates a new QueueMemberPenaltyEvent - /// - /// ManagerConnection passed through in the event. - public QueueMemberPenaltyEvent(ManagerConnection source) + /// ManagerConnection passed through in the event. + public QueueMemberPenaltyEvent(ManagerConnection source) : base(source) { } diff --git a/Asterisk.2013/Asterisk.NET/Manager/Event/QueueMemberRemovedEvent.cs b/Asterisk.2013/Asterisk.NET/Manager/Event/QueueMemberRemovedEvent.cs index b8d424d..27182e1 100644 --- a/Asterisk.2013/Asterisk.NET/Manager/Event/QueueMemberRemovedEvent.cs +++ b/Asterisk.2013/Asterisk.NET/Manager/Event/QueueMemberRemovedEvent.cs @@ -1,27 +1,21 @@ namespace AsterNET.Manager.Event { - /// - /// A QueueMemberRemovedEvent is triggered when a queue member is removed from a queue.
- /// It is implemented in apps/app_queue.c.
- /// - /// Available since : Asterisk 1.2.
- ///
- ///
- public class QueueMemberRemovedEvent : AbstractQueueMemberEvent + /// + /// A QueueMemberRemovedEvent is triggered when a queue member is removed from a queue.
+ /// It is implemented in apps/app_queue.c.
+ /// + /// Available since : Asterisk 1.2.
+ ///
+ ///
+ public class QueueMemberRemovedEvent : AbstractQueueMemberEvent { /// - /// Returns the name of the member's interface.
- /// E.g. the channel name or agent group. + /// Creates a new QueueMemberRemovedEvent ///
- public new string MemberName { get; set; } - - /// - /// Creates a new QueueMemberRemovedEvent - /// - /// ManagerConnection passed through in the event. + /// ManagerConnection passed through in the event. public QueueMemberRemovedEvent(ManagerConnection source) : base(source) { } } -} \ No newline at end of file +} diff --git a/Asterisk.2013/Asterisk.NET/Manager/Event/QueueMemberRinginuseEvent.cs b/Asterisk.2013/Asterisk.NET/Manager/Event/QueueMemberRinginuseEvent.cs index 97a2b23..05c1c0c 100644 --- a/Asterisk.2013/Asterisk.NET/Manager/Event/QueueMemberRinginuseEvent.cs +++ b/Asterisk.2013/Asterisk.NET/Manager/Event/QueueMemberRinginuseEvent.cs @@ -1,24 +1,17 @@ namespace AsterNET.Manager.Event { - /// - /// Raised when a member's ringinuse setting is changed - /// - public class QueueMemberRinginuseEvent : AbstractQueueMemberEvent - { - - /// - /// Evaluates if Ringinuse, - /// if not.
- ///
- public new bool Ringinuse { get; set; } - - /// - /// Creates a new QueueMemberRinginuseEvent - /// - /// ManagerConnection passed through in the event. + /// + /// Raised when a member's ringinuse setting is changed + /// + public class QueueMemberRinginuseEvent : AbstractQueueMemberEvent + { + /// + /// Creates a new QueueMemberRinginuseEvent + /// + /// ManagerConnection passed through in the event. public QueueMemberRinginuseEvent(ManagerConnection source) : base(source) { } } -} \ No newline at end of file +} diff --git a/Asterisk.2013/Asterisk.NET/Manager/Event/QueueMemberStatusEvent.cs b/Asterisk.2013/Asterisk.NET/Manager/Event/QueueMemberStatusEvent.cs index fb1fce9..8cafaf7 100644 --- a/Asterisk.2013/Asterisk.NET/Manager/Event/QueueMemberStatusEvent.cs +++ b/Asterisk.2013/Asterisk.NET/Manager/Event/QueueMemberStatusEvent.cs @@ -1,80 +1,17 @@ namespace AsterNET.Manager.Event { - /// - /// Raised when a Queue member's status has changed - /// - public class QueueMemberStatusEvent : AbstractQueueMemberEvent - { - /// - /// Returns the name of the member's interface.
- /// E.g. the channel name or agent group. - ///
- public new string MemberName { get; set; } - - /// - /// Channel technology or location from which to read device state changes.
- ///
- public new string StateInterface { get; set; } - - /// - /// Get/Set if the added member is a dynamic or static queue member. - /// "dynamic" if the added member is a dynamic queue member, - /// "static" if the added member is a static queue member. - /// - public new string Membership { get; set; } - - /// - /// Get/Set the penalty for the added member. When calls are distributed - /// members with higher penalties are considered last. - /// - public new int Penalty { get; set; } - - /// - /// Get/Set the number of calls answered by the member. - /// - public new int CallsTaken { get; set; } - - /// - /// Get/Set the time (in seconds since 01/01/1970) the last successful call answered by the added member was hungup. - /// - public new long LastCall { get; set; } - - /// - /// Evaluates if member is in call, - /// after LastCall time is updated.
- ///
- public new bool InCall { get; set; } - - /// - /// Get/Set the status of this queue member.
- /// Valid status codes are:
- /// - /// AST_DEVICE_UNKNOWN - /// AST_DEVICE_NOT_INUSE - /// AST_DEVICE_INUSE - /// AST_DEVICE_BUSY - /// AST_DEVICE_INVALID - /// AST_DEVICE_UNAVAILABLE - /// AST_DEVICE_RINGING - /// AST_DEVICE_RINGINUSE - /// AST_DEVICE_ONHOLD - /// - ///
- public new int Status { get; set; } - - /// - /// Get/Set value if this queue member is paused (not accepting calls).
- /// true if this member has been paused or false if not. - ///
- public new bool Paused { get; set; } - - /// - /// Creates a new QueueMemberStatusEvent - /// - /// ManagerConnection passed through in the event. + /// + /// Raised when a Queue member's status has changed + /// + public class QueueMemberStatusEvent : AbstractQueueMemberEvent + { + /// + /// Creates a new QueueMemberStatusEvent + /// + /// ManagerConnection passed through in the event. public QueueMemberStatusEvent(ManagerConnection source) : base(source) { } } -} \ No newline at end of file +} diff --git a/Asterisk.2013/Asterisk.NET/Manager/Event/QueueSummaryEvent.cs b/Asterisk.2013/Asterisk.NET/Manager/Event/QueueSummaryEvent.cs new file mode 100644 index 0000000..9f48db6 --- /dev/null +++ b/Asterisk.2013/Asterisk.NET/Manager/Event/QueueSummaryEvent.cs @@ -0,0 +1,48 @@ +namespace AsterNET.Manager.Event +{ + /// + /// + /// + public class QueueSummaryEvent : ManagerEvent + { + public QueueSummaryEvent(ManagerConnection source) + : base(source) + { + } + + /// + /// Queue name + /// + public string Queue { get; set; } + + /// + /// Logged operators count in queue + /// + public int LoggedIn { get; set; } + + /// + /// Available operators in queue + /// + public int Available { get; set; } + + /// + /// Calls count + /// + public int Callers { get; set; } + + /// + /// + /// + public int HoldTime { get; set; } + + /// + /// Total talk time + /// + public int TalkTime { get; set; } + + /// + /// + /// + public int LongestHoldTime { get; set; } + } +} diff --git a/Asterisk.2013/Asterisk.NET/Manager/Event/SuccessfulAuthEvent.cs b/Asterisk.2013/Asterisk.NET/Manager/Event/SuccessfulAuthEvent.cs new file mode 100644 index 0000000..32f7570 --- /dev/null +++ b/Asterisk.2013/Asterisk.NET/Manager/Event/SuccessfulAuthEvent.cs @@ -0,0 +1,16 @@ +namespace AsterNET.Manager.Event +{ + + /// + /// Raised when a request successfully authenticates with a service..
+ ///
+ public class SuccessfulAuthEvent : ManagerEvent + { + public SuccessfulAuthEvent(ManagerConnection source) + : base(source) + { + } + + public string Status { get; set; } + } +} \ No newline at end of file diff --git a/Asterisk.2013/Asterisk.NET/Manager/ManagerConnection.cs b/Asterisk.2013/Asterisk.NET/Manager/ManagerConnection.cs index 5620d3f..d1fe667 100644 --- a/Asterisk.2013/Asterisk.NET/Manager/ManagerConnection.cs +++ b/Asterisk.2013/Asterisk.NET/Manager/ManagerConnection.cs @@ -196,7 +196,7 @@ namespace AsterNET.Manager /// A MeetMeLeave is triggered if a channel leaves a meet me conference.
///
public event EventHandler MeetMeLeave; - // public event MeetMeStopTalkingEventHandler MeetMeStopTalking; + // public event EventHandler MeetMeStopTalking; /// /// A MeetMeTalkingEvent is triggered when a user starts talking in a meet me conference.
/// To enable talker detection you must pass the option 'T' to the MeetMe application. @@ -222,15 +222,15 @@ namespace AsterNET.Manager /// A NewState is triggered when the state of a channel has changed.
///
public event EventHandler NewState; - // public event OriginateEventHandler Originate; + // public event EventHandler Originate; /// /// An OriginateFailure is triggered when the execution of an OriginateAction failed. /// - // public event OriginateFailureEventHandler OriginateFailure; + // public event EventHandler OriginateFailure; /// /// An OriginateSuccess is triggered when the execution of an OriginateAction succeeded. /// - // public event OriginateSuccessEventHandler OriginateSuccess; + // public event EventHandler OriginateSuccess; /// /// An OriginateResponse is triggered when the execution of an Originate. /// @@ -426,6 +426,36 @@ namespace AsterNET.Manager /// public event EventHandler QueueMemberPause; + /// + /// A ChallengeResponseFailed is triggered when a request's attempt to authenticate has been challenged, and the request failed the authentication challenge. + /// + public event EventHandler ChallengeResponseFailed; + + /// + /// A InvalidAccountID is triggered when a request fails an authentication check due to an invalid account ID. + /// + public event EventHandler InvalidAccountID; + + /// + /// A DeviceStateChanged is triggered when a device state changes. + /// + public event EventHandler DeviceStateChanged; + + /// + /// A ChallengeSent is triggered when an Asterisk service sends an authentication challenge to a request.. + /// + public event EventHandler ChallengeSent; + + /// + /// A SuccessfulAuth is triggered when a request successfully authenticates with a service. + /// + public event EventHandler SuccessfulAuth; + + /// + /// Raised when call queue summary + /// + public event EventHandler QueueSummary; + #endregion #region Constructor - ManagerConnection() @@ -462,7 +492,6 @@ namespace AsterNET.Manager Helper.RegisterEventHandler(registeredEventHandlers, typeof(DBGetResponseEvent), arg => fireEvent(DBGetResponse, arg)); Helper.RegisterEventHandler(registeredEventHandlers, typeof(DialEvent), arg => fireEvent(Dial, arg)); - Helper.RegisterEventHandler(registeredEventHandlers, typeof(DNDStateEvent), arg => fireEvent(DNDState, arg)); Helper.RegisterEventHandler(registeredEventHandlers, typeof(ExtensionStatusEvent), arg => fireEvent(ExtensionStatus, arg)); Helper.RegisterEventHandler(registeredEventHandlers, typeof(HangupEvent), arg => fireEvent(Hangup, arg)); @@ -484,8 +513,8 @@ namespace AsterNET.Manager Helper.RegisterEventHandler(registeredEventHandlers, typeof(ParkedCallEvent), arg => fireEvent(ParkedCall, arg)); Helper.RegisterEventHandler(registeredEventHandlers, typeof(ParkedCallGiveUpEvent), arg => fireEvent(ParkedCallGiveUp, arg)); Helper.RegisterEventHandler(registeredEventHandlers, typeof(ParkedCallsCompleteEvent), arg => fireEvent(ParkedCallsComplete, arg)); - Helper.RegisterEventHandler(registeredEventHandlers, typeof(ParkedCallTimeOutEvent), arg => fireEvent(ParkedCallsComplete, arg)); - Helper.RegisterEventHandler(registeredEventHandlers, typeof(PeerEntryEvent), arg => fireEvent(ParkedCallTimeOut, arg)); + Helper.RegisterEventHandler(registeredEventHandlers, typeof(ParkedCallTimeOutEvent), arg => fireEvent(ParkedCallTimeOut, arg)); + Helper.RegisterEventHandler(registeredEventHandlers, typeof(PeerEntryEvent), arg => fireEvent(PeerEntry, arg)); Helper.RegisterEventHandler(registeredEventHandlers, typeof(PeerlistCompleteEvent), arg => fireEvent(PeerlistComplete, arg)); Helper.RegisterEventHandler(registeredEventHandlers, typeof(PeerStatusEvent), arg => fireEvent(PeerStatus, arg)); Helper.RegisterEventHandler(registeredEventHandlers, typeof(QueueEntryEvent), arg => fireEvent(QueueEntry, arg)); @@ -540,11 +569,16 @@ namespace AsterNET.Manager Helper.RegisterEventHandler(registeredEventHandlers, typeof(QueueCallerJoinEvent), arg => fireEvent(QueueCallerJoin, arg)); Helper.RegisterEventHandler(registeredEventHandlers, typeof(QueueCallerLeaveEvent), arg => fireEvent(QueueCallerLeave, arg)); Helper.RegisterEventHandler(registeredEventHandlers, typeof(QueueMemberPauseEvent), arg => fireEvent(QueueMemberPause, arg)); - + Helper.RegisterEventHandler(registeredEventHandlers, typeof(ChallengeResponseFailedEvent), arg => fireEvent(ChallengeResponseFailed, arg)); + Helper.RegisterEventHandler(registeredEventHandlers, typeof(InvalidAccountIDEvent), arg => fireEvent(InvalidAccountID, arg)); + Helper.RegisterEventHandler(registeredEventHandlers, typeof(DeviceStateChangeEvent), arg => fireEvent(DeviceStateChanged, arg)); + Helper.RegisterEventHandler(registeredEventHandlers, typeof(ChallengeSentEvent), arg => fireEvent(ChallengeSent, arg)); + Helper.RegisterEventHandler(registeredEventHandlers, typeof(SuccessfulAuthEvent), arg => fireEvent(SuccessfulAuth, arg)); + Helper.RegisterEventHandler(registeredEventHandlers, typeof(QueueSummaryEvent), arg => fireEvent(QueueSummary, arg)); + #endregion this.internalEvent += new EventHandler(internalEventHandler); - } #endregion @@ -574,7 +608,7 @@ namespace AsterNET.Manager /// the port where Asterisk listens for incoming Manager API connections, usually 5038. /// the username to use for login /// the password to use for login - /// text encoding to asterisk input/output stream + /// text encoding to asterisk input/output stream public ManagerConnection(string hostname, int port, string username, string password, Encoding encoding) : this() { @@ -1180,7 +1214,7 @@ namespace AsterNET.Manager enableEvents = true; reconnected = false; disconnect(true); - fireInternalEvent(new DisconnectEvent(this)); + fireEvent(new DisconnectEvent(this)); } } #endregion @@ -1763,7 +1797,7 @@ namespace AsterNET.Manager ConnectEvent ce = new ConnectEvent(this); ce.Reconnect = true; ce.ProtocolIdentifier = protocolIdentifier; - fireInternalEvent(ce); + fireEvent(ce); } else if (keepAliveAfterAuthenticationFailure) reconnect(true); @@ -1861,32 +1895,30 @@ namespace AsterNET.Manager if (reconnected && e is DisconnectEvent) { ((DisconnectEvent)e).Reconnect = true; - fireInternalEvent(e); + fireEvent(e); reconnect(false); } else if (!reconnected && reconnectEnable && (e is DisconnectEvent || e is ReloadEvent || e is ShutdownEvent)) { ((ConnectionStateEvent)e).Reconnect = true; - fireInternalEvent(e); + fireEvent(e); reconnect(true); } else - fireInternalEvent(e); + fireEvent(e); } private void eventComplete(IAsyncResult result) { } - private void fireInternalEvent(ManagerEvent e) + private void fireEvent(ManagerEvent e) { if (enableEvents && internalEvent != null) - { if (UseASyncEvents) internalEvent.BeginInvoke(this, e, new AsyncCallback(eventComplete), null); else internalEvent.Invoke(this, e); - } } /// @@ -1907,4 +1939,4 @@ namespace AsterNET.Manager } #endregion } -} \ No newline at end of file +} diff --git a/README.md b/README.md index 4396a66..b0ac189 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,5 @@ [![Build Status](https://travis-ci.org/AsterNET/AsterNET.svg?branch=master)](https://travis-ci.org/AsterNET/AsterNET) +[![NuGet](https://img.shields.io/nuget/v/AsterNET.svg)](https://www.nuget.org/packages/AsterNET) AsterNET is an open source framework for Asterisk AMI and FastAGI. AsterNET allows you to talk to Asterisk AMI from any .NET application and create FastAGI applications in any .NET language.