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:
Deantwo 2018-07-10 14:58:39 +02:00 committed by GitHub
commit 9fd1a1c8ca
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 1803 additions and 2315 deletions

View file

@ -138,13 +138,13 @@ Ctrl-C to exit");
manager.RegisterUserEventClass(typeof(UserAgentLoginEvent));
// Add or Remove events
manager.UserEvents += new UserEventHandler(dam_UserEvents);
manager.UserEvents += new EventHandler<UserEvent>(dam_UserEvents);
// Dont't display this event
manager.NewExten += new NewExtenEventHandler(manager_IgnoreEvent);
manager.NewExten += new EventHandler<NewExtenEvent>(manager_IgnoreEvent);
// Display all other
manager.UnhandledEvent += new ManagerEventHandler(dam_Events);
manager.UnhandledEvent += new EventHandler<ManagerEvent>(dam_Events);
// +++ Only to debug purpose
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.");
// Wait for Dial Event from ORIGINATE_CHANNEL
DialEventHandler de = new DialEventHandler(dam_Dial);
EventHandler<DialEvent> de = new EventHandler<DialEvent>(dam_Dial);
manager.Dial += de;
while (transferChannel == null)
{
@ -323,7 +323,7 @@ Ctrl-C to exit");
// Link event used to define monitor channel
Console.WriteLine("Monitor call. Please call " + ORIGINATE_CHANNEL + " and answer or press ESC.");
// Wait for Link event
LinkEventHandler le = new LinkEventHandler(dam_Link);
EventHandler<LinkEvent> le = new EventHandler<LinkEvent>(dam_Link);
manager.Link += le;
while (monitorChannel == null)
{

View file

@ -28,7 +28,7 @@ namespace AsterNET.WinForm
btnConnect.Enabled = false;
manager = new ManagerConnection(address, port, user, password);
manager.UnhandledEvent += new ManagerEventHandler(manager_Events);
manager.UnhandledEvent += new EventHandler<ManagerEvent>(manager_Events);
try
{
// Uncomment next 2 line comments to Disable timeout (debug mode)

View file

@ -167,6 +167,7 @@
<Compile Include="Manager\Action\DBPutAction.cs" />
<Compile Include="Manager\Action\EventsAction.cs" />
<Compile Include="Manager\Action\ExtensionStateAction.cs" />
<Compile Include="Manager\Action\FilterAction.cs" />
<Compile Include="Manager\Action\GetConfigAction.cs" />
<Compile Include="Manager\Action\GetVarAction.cs" />
<Compile Include="Manager\Action\HangupAction.cs" />
@ -195,6 +196,7 @@
<Compile Include="Manager\Action\QueueResetAction.cs" />
<Compile Include="Manager\Action\QueueRuleAction.cs" />
<Compile Include="Manager\Action\QueueStatusAction.cs" />
<Compile Include="Manager\Action\QueueSummaryAction.cs" />
<Compile Include="Manager\Action\RedirectAction.cs" />
<Compile Include="Manager\Action\SetCDRUserFieldAction.cs" />
<Compile Include="Manager\Action\SetVarAction.cs" />
@ -256,6 +258,7 @@
<Compile Include="Manager\Event\QueueMemberPauseEvent.cs" />
<Compile Include="Manager\Event\QueueMemberPenaltyEvent.cs" />
<Compile Include="Manager\Event\QueueMemberRinginuseEvent.cs" />
<Compile Include="Manager\Event\QueueSummaryEvent.cs" />
<Compile Include="Manager\Event\RTPReceiverStatEvent.cs" />
<Compile Include="Manager\Event\RTCPSentEvent.cs" />
<Compile Include="Manager\Event\RTCPReceivedEvent.cs" />

View file

@ -874,12 +874,13 @@ namespace AsterNET
#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))
throw new ArgumentException("Event class already registered : " + eventType.Name);
list.Add(eventHash, index);
throw new ArgumentException("Event class already registered : " + eventTypeName);
list.Add(eventHash, action);
}
#endregion

View 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
}
}

View file

@ -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
}
}

View file

@ -1,16 +1,16 @@
namespace AsterNET.Manager.Event
{
/// <summary>
/// Raised when an Asterisk service sends an authentication challenge to a request..<br />
/// </summary>
public class ChallengeSentEvent : ManagerEvent
{
public ChallengeSentEvent(ManagerConnection source)
: base(source)
{
}
public string Status { get; set; }
}
namespace AsterNET.Manager.Event
{
/// <summary>
/// Raised when an Asterisk service sends an authentication challenge to a request..<br />
/// </summary>
public class ChallengeSentEvent : ManagerEvent
{
public ChallengeSentEvent(ManagerConnection source)
: base(source)
{
}
public string Status { get; set; }
}
}

View file

@ -1,17 +1,17 @@
namespace AsterNET.Manager.Event
{
/// <summary>
/// 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.
/// </summary>
public class DeviceStateChangeEvent : ManagerEvent
{
public DeviceStateChangeEvent(ManagerConnection source)
: base(source)
{
}
public string Status { get; set; }
}
namespace AsterNET.Manager.Event
{
/// <summary>
/// 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.
/// </summary>
public class DeviceStateChangeEvent : ManagerEvent
{
public DeviceStateChangeEvent(ManagerConnection source)
: base(source)
{
}
public string Status { get; set; }
}
}

View file

@ -1,16 +1,16 @@
namespace AsterNET.Manager.Event
{
/// <summary>
/// Raised when a request fails an authentication check due to an invalid account ID.<br />
/// </summary>
public class InvalidAccountIDEvent : ManagerEvent
{
public InvalidAccountIDEvent(ManagerConnection source)
: base(source)
{
}
public string Status { get; set; }
}
namespace AsterNET.Manager.Event
{
/// <summary>
/// Raised when a request fails an authentication check due to an invalid account ID.<br />
/// </summary>
public class InvalidAccountIDEvent : ManagerEvent
{
public InvalidAccountIDEvent(ManagerConnection source)
: base(source)
{
}
public string Status { get; set; }
}
}

View file

@ -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; }
}
}

View file

@ -1,16 +1,16 @@
namespace AsterNET.Manager.Event
{
/// <summary>
/// Raised when a request successfully authenticates with a service..<br />
/// </summary>
public class SuccessfulAuthEvent : ManagerEvent
{
public SuccessfulAuthEvent(ManagerConnection source)
: base(source)
{
}
public string Status { get; set; }
}
namespace AsterNET.Manager.Event
{
/// <summary>
/// Raised when a request successfully authenticates with a service..<br />
/// </summary>
public class SuccessfulAuthEvent : ManagerEvent
{
public SuccessfulAuthEvent(ManagerConnection source)
: base(source)
{
}
public string Status { get; set; }
}
}

File diff suppressed because it is too large Load diff