Used EventHandler<T> delegate because the event signature is the same for all. Changed the call of the event so that the indexes are not used. Action<ManagerEvent> allows you to use the delegate value at the current real time

This commit is contained in:
zsender 2017-04-05 08:32:55 +03:00
parent fd6cdce95c
commit 5e738cdd3c
4 changed files with 1545 additions and 2187 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 += dam_UserEvents;
// Dont't display this event
manager.NewExten += new NewExtenEventHandler(manager_IgnoreEvent);
manager.NewExten += manager_IgnoreEvent;
// Display all other
manager.UnhandledEvent += new ManagerEventHandler(dam_Events);
manager.UnhandledEvent += 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 = 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 = 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 += manager_Events;
try
{
// Uncomment next 2 line comments to Disable timeout (debug mode)

View file

@ -872,14 +872,15 @@ namespace AsterNET
#endregion
#region RegisterEventHandler(Dictionary<int, int> list, int index, Type eventType)
#region RegisterEventHandler(Dictionary<int, Action<ManagerEvent>> list, Type eventType, Action<ManagerEvent> action)
internal static void RegisterEventHandler(Dictionary<int, int> list, int index, Type eventType)
internal static void RegisterEventHandler(Dictionary<int, Action<ManagerEvent>> list, Type eventType, Action<ManagerEvent> 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

File diff suppressed because it is too large Load diff