Merge pull request #93 from zsender/features/Improvement_calling_event
#93 Improvement calling events #92 Added command action: FilterAction, QueueSummaryAction
This commit is contained in:
commit
9fd1a1c8ca
12 changed files with 1803 additions and 2315 deletions
|
@ -138,13 +138,13 @@ Ctrl-C to exit");
|
||||||
manager.RegisterUserEventClass(typeof(UserAgentLoginEvent));
|
manager.RegisterUserEventClass(typeof(UserAgentLoginEvent));
|
||||||
|
|
||||||
// Add or Remove events
|
// Add or Remove events
|
||||||
manager.UserEvents += new UserEventHandler(dam_UserEvents);
|
manager.UserEvents += new EventHandler<UserEvent>(dam_UserEvents);
|
||||||
|
|
||||||
// Dont't display this event
|
// Dont't display this event
|
||||||
manager.NewExten += new NewExtenEventHandler(manager_IgnoreEvent);
|
manager.NewExten += new EventHandler<NewExtenEvent>(manager_IgnoreEvent);
|
||||||
|
|
||||||
// Display all other
|
// Display all other
|
||||||
manager.UnhandledEvent += new ManagerEventHandler(dam_Events);
|
manager.UnhandledEvent += new EventHandler<ManagerEvent>(dam_Events);
|
||||||
|
|
||||||
// +++ Only to debug purpose
|
// +++ Only to debug purpose
|
||||||
manager.FireAllEvents = true;
|
manager.FireAllEvents = true;
|
||||||
|
@ -288,7 +288,7 @@ Ctrl-C to exit");
|
||||||
|
|
||||||
Console.WriteLine("Redirect Call from " + ORIGINATE_CHANNEL + " to " + ORIGINATE_EXTRA_CHANNEL + " or press ESC.");
|
Console.WriteLine("Redirect Call from " + ORIGINATE_CHANNEL + " to " + ORIGINATE_EXTRA_CHANNEL + " or press ESC.");
|
||||||
// Wait for Dial Event from ORIGINATE_CHANNEL
|
// Wait for Dial Event from ORIGINATE_CHANNEL
|
||||||
DialEventHandler de = new DialEventHandler(dam_Dial);
|
EventHandler<DialEvent> de = new EventHandler<DialEvent>(dam_Dial);
|
||||||
manager.Dial += de;
|
manager.Dial += de;
|
||||||
while (transferChannel == null)
|
while (transferChannel == null)
|
||||||
{
|
{
|
||||||
|
@ -323,7 +323,7 @@ Ctrl-C to exit");
|
||||||
// Link event used to define monitor channel
|
// Link event used to define monitor channel
|
||||||
Console.WriteLine("Monitor call. Please call " + ORIGINATE_CHANNEL + " and answer or press ESC.");
|
Console.WriteLine("Monitor call. Please call " + ORIGINATE_CHANNEL + " and answer or press ESC.");
|
||||||
// Wait for Link event
|
// Wait for Link event
|
||||||
LinkEventHandler le = new LinkEventHandler(dam_Link);
|
EventHandler<LinkEvent> le = new EventHandler<LinkEvent>(dam_Link);
|
||||||
manager.Link += le;
|
manager.Link += le;
|
||||||
while (monitorChannel == null)
|
while (monitorChannel == null)
|
||||||
{
|
{
|
||||||
|
|
|
@ -28,7 +28,7 @@ namespace AsterNET.WinForm
|
||||||
|
|
||||||
btnConnect.Enabled = false;
|
btnConnect.Enabled = false;
|
||||||
manager = new ManagerConnection(address, port, user, password);
|
manager = new ManagerConnection(address, port, user, password);
|
||||||
manager.UnhandledEvent += new ManagerEventHandler(manager_Events);
|
manager.UnhandledEvent += new EventHandler<ManagerEvent>(manager_Events);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// Uncomment next 2 line comments to Disable timeout (debug mode)
|
// Uncomment next 2 line comments to Disable timeout (debug mode)
|
||||||
|
|
|
@ -167,6 +167,7 @@
|
||||||
<Compile Include="Manager\Action\DBPutAction.cs" />
|
<Compile Include="Manager\Action\DBPutAction.cs" />
|
||||||
<Compile Include="Manager\Action\EventsAction.cs" />
|
<Compile Include="Manager\Action\EventsAction.cs" />
|
||||||
<Compile Include="Manager\Action\ExtensionStateAction.cs" />
|
<Compile Include="Manager\Action\ExtensionStateAction.cs" />
|
||||||
|
<Compile Include="Manager\Action\FilterAction.cs" />
|
||||||
<Compile Include="Manager\Action\GetConfigAction.cs" />
|
<Compile Include="Manager\Action\GetConfigAction.cs" />
|
||||||
<Compile Include="Manager\Action\GetVarAction.cs" />
|
<Compile Include="Manager\Action\GetVarAction.cs" />
|
||||||
<Compile Include="Manager\Action\HangupAction.cs" />
|
<Compile Include="Manager\Action\HangupAction.cs" />
|
||||||
|
@ -195,6 +196,7 @@
|
||||||
<Compile Include="Manager\Action\QueueResetAction.cs" />
|
<Compile Include="Manager\Action\QueueResetAction.cs" />
|
||||||
<Compile Include="Manager\Action\QueueRuleAction.cs" />
|
<Compile Include="Manager\Action\QueueRuleAction.cs" />
|
||||||
<Compile Include="Manager\Action\QueueStatusAction.cs" />
|
<Compile Include="Manager\Action\QueueStatusAction.cs" />
|
||||||
|
<Compile Include="Manager\Action\QueueSummaryAction.cs" />
|
||||||
<Compile Include="Manager\Action\RedirectAction.cs" />
|
<Compile Include="Manager\Action\RedirectAction.cs" />
|
||||||
<Compile Include="Manager\Action\SetCDRUserFieldAction.cs" />
|
<Compile Include="Manager\Action\SetCDRUserFieldAction.cs" />
|
||||||
<Compile Include="Manager\Action\SetVarAction.cs" />
|
<Compile Include="Manager\Action\SetVarAction.cs" />
|
||||||
|
@ -256,6 +258,7 @@
|
||||||
<Compile Include="Manager\Event\QueueMemberPauseEvent.cs" />
|
<Compile Include="Manager\Event\QueueMemberPauseEvent.cs" />
|
||||||
<Compile Include="Manager\Event\QueueMemberPenaltyEvent.cs" />
|
<Compile Include="Manager\Event\QueueMemberPenaltyEvent.cs" />
|
||||||
<Compile Include="Manager\Event\QueueMemberRinginuseEvent.cs" />
|
<Compile Include="Manager\Event\QueueMemberRinginuseEvent.cs" />
|
||||||
|
<Compile Include="Manager\Event\QueueSummaryEvent.cs" />
|
||||||
<Compile Include="Manager\Event\RTPReceiverStatEvent.cs" />
|
<Compile Include="Manager\Event\RTPReceiverStatEvent.cs" />
|
||||||
<Compile Include="Manager\Event\RTCPSentEvent.cs" />
|
<Compile Include="Manager\Event\RTCPSentEvent.cs" />
|
||||||
<Compile Include="Manager\Event\RTCPReceivedEvent.cs" />
|
<Compile Include="Manager\Event\RTCPReceivedEvent.cs" />
|
||||||
|
|
|
@ -874,12 +874,13 @@ namespace AsterNET
|
||||||
|
|
||||||
#region RegisterEventHandler(Dictionary<int, int> list, int index, Type eventType)
|
#region RegisterEventHandler(Dictionary<int, int> list, int index, Type eventType)
|
||||||
|
|
||||||
internal static void RegisterEventHandler(Dictionary<int, int> list, int index, Type eventType)
|
internal static void RegisterEventHandler(Dictionary<int, Func<ManagerEvent, bool>> list, Type eventType, Func<ManagerEvent, bool> action)
|
||||||
{
|
{
|
||||||
int eventHash = eventType.Name.GetHashCode();
|
var eventTypeName = eventType.Name;
|
||||||
|
int eventHash = eventTypeName.GetHashCode();
|
||||||
if (list.ContainsKey(eventHash))
|
if (list.ContainsKey(eventHash))
|
||||||
throw new ArgumentException("Event class already registered : " + eventType.Name);
|
throw new ArgumentException("Event class already registered : " + eventTypeName);
|
||||||
list.Add(eventHash, index);
|
list.Add(eventHash, action);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
57
Asterisk.2013/Asterisk.NET/Manager/Action/FilterAction.cs
Normal file
57
Asterisk.2013/Asterisk.NET/Manager/Action/FilterAction.cs
Normal file
|
@ -0,0 +1,57 @@
|
||||||
|
namespace AsterNET.Manager.Action
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 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
|
||||||
|
/// </summary>
|
||||||
|
public class FilterAction : ManagerAction
|
||||||
|
{
|
||||||
|
#region Action
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Get the name of this action, i.e. "Filter".
|
||||||
|
/// </summary>
|
||||||
|
public override string Action
|
||||||
|
{
|
||||||
|
get { return "Filter"; }
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Operation
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Add - Add a filter
|
||||||
|
/// </summary>
|
||||||
|
public string Operation { get; set; }
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Filter
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Filters can be whitelist or blacklist
|
||||||
|
/// Example whitelist filter: "Event: Newchannel"
|
||||||
|
/// Example blacklist filter: "!Channel: DAHDI.*"
|
||||||
|
/// </summary>
|
||||||
|
public string Filter { get; set; }
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region FilterAction(string filter)
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Add - Add a filter
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="filter">Add a filter</param>
|
||||||
|
/// <param name="operation">Filters can be whitelist or blacklist</param>
|
||||||
|
public FilterAction(string filter, string operation = "Add")
|
||||||
|
{
|
||||||
|
Filter = filter;
|
||||||
|
Operation = operation;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,51 @@
|
||||||
|
using AsterNET.Manager.Event;
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace AsterNET.Manager.Action
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Show queue summary
|
||||||
|
/// </summary>
|
||||||
|
/// <seealso cref="Manager.Action.QueueStatusAction" />
|
||||||
|
public class QueueSummaryAction : ManagerActionEvent
|
||||||
|
{
|
||||||
|
#region Action
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Get the name of this action, i.e. "Filter".
|
||||||
|
/// </summary>
|
||||||
|
public override string Action
|
||||||
|
{
|
||||||
|
get { return "QueueSummary"; }
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region MyRegion
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Name of queue
|
||||||
|
/// </summary>
|
||||||
|
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
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,16 +1,16 @@
|
||||||
namespace AsterNET.Manager.Event
|
namespace AsterNET.Manager.Event
|
||||||
{
|
{
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Raised when an Asterisk service sends an authentication challenge to a request..<br />
|
/// Raised when an Asterisk service sends an authentication challenge to a request..<br />
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class ChallengeSentEvent : ManagerEvent
|
public class ChallengeSentEvent : ManagerEvent
|
||||||
{
|
{
|
||||||
public ChallengeSentEvent(ManagerConnection source)
|
public ChallengeSentEvent(ManagerConnection source)
|
||||||
: base(source)
|
: base(source)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public string Status { get; set; }
|
public string Status { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,17 +1,17 @@
|
||||||
namespace AsterNET.Manager.Event
|
namespace AsterNET.Manager.Event
|
||||||
{
|
{
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Raised when a device state changes.<br />
|
/// Raised when a device state changes.<br />
|
||||||
/// This differs from the ExtensionStatus event because this event is raised for all device state changes, not only for changes that affect dialplan hints.
|
/// This differs from the ExtensionStatus event because this event is raised for all device state changes, not only for changes that affect dialplan hints.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class DeviceStateChangeEvent : ManagerEvent
|
public class DeviceStateChangeEvent : ManagerEvent
|
||||||
{
|
{
|
||||||
public DeviceStateChangeEvent(ManagerConnection source)
|
public DeviceStateChangeEvent(ManagerConnection source)
|
||||||
: base(source)
|
: base(source)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public string Status { get; set; }
|
public string Status { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,16 +1,16 @@
|
||||||
namespace AsterNET.Manager.Event
|
namespace AsterNET.Manager.Event
|
||||||
{
|
{
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Raised when a request fails an authentication check due to an invalid account ID.<br />
|
/// Raised when a request fails an authentication check due to an invalid account ID.<br />
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class InvalidAccountIDEvent : ManagerEvent
|
public class InvalidAccountIDEvent : ManagerEvent
|
||||||
{
|
{
|
||||||
public InvalidAccountIDEvent(ManagerConnection source)
|
public InvalidAccountIDEvent(ManagerConnection source)
|
||||||
: base(source)
|
: base(source)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public string Status { get; set; }
|
public string Status { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -0,0 +1,48 @@
|
||||||
|
namespace AsterNET.Manager.Event
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public class QueueSummaryEvent : ManagerEvent
|
||||||
|
{
|
||||||
|
public QueueSummaryEvent(ManagerConnection source)
|
||||||
|
: base(source)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Queue name
|
||||||
|
/// </summary>
|
||||||
|
public string Queue { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Logged operators count in queue
|
||||||
|
/// </summary>
|
||||||
|
public int LoggedIn { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Available operators in queue
|
||||||
|
/// </summary>
|
||||||
|
public int Available { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Calls count
|
||||||
|
/// </summary>
|
||||||
|
public int Callers { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public int HoldTime { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Total talk time
|
||||||
|
/// </summary>
|
||||||
|
public int TalkTime { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public int LongestHoldTime { get; set; }
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,16 +1,16 @@
|
||||||
namespace AsterNET.Manager.Event
|
namespace AsterNET.Manager.Event
|
||||||
{
|
{
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Raised when a request successfully authenticates with a service..<br />
|
/// Raised when a request successfully authenticates with a service..<br />
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class SuccessfulAuthEvent : ManagerEvent
|
public class SuccessfulAuthEvent : ManagerEvent
|
||||||
{
|
{
|
||||||
public SuccessfulAuthEvent(ManagerConnection source)
|
public SuccessfulAuthEvent(ManagerConnection source)
|
||||||
: base(source)
|
: base(source)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public string Status { get; set; }
|
public string Status { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue