Merge pull request #72 from herman1vdb/master
Add some events for Asterisk 13 support
This commit is contained in:
commit
76505e2250
|
@ -232,7 +232,11 @@
|
|||
<Compile Include="Manager\Event\BridgeEvent.cs" />
|
||||
<Compile Include="Manager\Event\ChannelReloadEvent.cs" />
|
||||
<Compile Include="Manager\Event\ChannelUpdateEvent.cs" />
|
||||
<Compile Include="Manager\Event\DialEndEvent.cs" />
|
||||
<Compile Include="Manager\Event\DialBeginEvent.cs" />
|
||||
<Compile Include="Manager\Event\FailedACLEvent.cs" />
|
||||
<Compile Include="Manager\Event\QueueCallerJoinEvent.cs" />
|
||||
<Compile Include="Manager\Event\QueueCallerLeaveEvent.cs" />
|
||||
<Compile Include="Manager\Event\MeetmeMuteEvent.cs" />
|
||||
<Compile Include="Manager\Event\DTMFEvent.cs" />
|
||||
<Compile Include="Manager\Event\FaxReceivedEvent.cs" />
|
||||
|
@ -247,6 +251,7 @@
|
|||
<Compile Include="Manager\Event\NewAccountCodeEvent.cs" />
|
||||
<Compile Include="Manager\Event\OriginateResponseEvent.cs" />
|
||||
<Compile Include="Manager\Event\PRIEvent.cs" />
|
||||
<Compile Include="Manager\Event\QueueMemberPauseEvent.cs" />
|
||||
<Compile Include="Manager\Event\QueueMemberPenaltyEvent.cs" />
|
||||
<Compile Include="Manager\Event\RTPReceiverStatEvent.cs" />
|
||||
<Compile Include="Manager\Event\RTCPSentEvent.cs" />
|
||||
|
|
16
Asterisk.2013/Asterisk.NET/Manager/Event/DialBeginEvent.cs
Normal file
16
Asterisk.2013/Asterisk.NET/Manager/Event/DialBeginEvent.cs
Normal file
|
@ -0,0 +1,16 @@
|
|||
namespace AsterNET.Manager.Event
|
||||
{
|
||||
/// <summary>
|
||||
/// A dial begin event is triggered whenever when a dial action has started.<br/>
|
||||
/// </summary>
|
||||
public class DialBeginEvent : DialEvent
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a new DialBeginEvent.
|
||||
/// </summary>
|
||||
public DialBeginEvent(ManagerConnection source)
|
||||
: base(source)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
18
Asterisk.2013/Asterisk.NET/Manager/Event/DialEndEvent.cs
Normal file
18
Asterisk.2013/Asterisk.NET/Manager/Event/DialEndEvent.cs
Normal file
|
@ -0,0 +1,18 @@
|
|||
namespace AsterNET.Manager.Event
|
||||
{
|
||||
/// <summary>
|
||||
/// A dial begin event is triggered whenever when a dial action has completed.<br/>
|
||||
/// </summary>
|
||||
public class DialEndEvent : DialEvent
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a new DialEndEvent.
|
||||
/// </summary>
|
||||
public DialEndEvent(ManagerConnection source)
|
||||
: base(source)
|
||||
{
|
||||
}
|
||||
|
||||
public string Forward { get; set; }
|
||||
}
|
||||
}
|
|
@ -1,5 +1,4 @@
|
|||
using System;
|
||||
using System.Text;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace AsterNET.Manager.Event
|
||||
|
@ -8,134 +7,90 @@ namespace AsterNET.Manager.Event
|
|||
/// Abstract base class for all Events that can be received from the Asterisk server.<br/>
|
||||
/// Events contain data pertaining to an event generated from within the Asterisk
|
||||
/// core or an extension module.<br/>
|
||||
/// There is one conrete subclass of ManagerEvent per each supported Asterisk
|
||||
/// Event.
|
||||
/// There is one conrete subclass of ManagerEvent per each supported Asterisk Event.
|
||||
///
|
||||
/// Channel / Privilege / UniqueId are not common to all events and should be moved to
|
||||
/// derived event classes.
|
||||
/// </summary>
|
||||
public abstract class ManagerEvent : EventArgs, IParseSupport
|
||||
{
|
||||
private DateTime dateReceived;
|
||||
private string privilege;
|
||||
private string server;
|
||||
private double timestamp;
|
||||
#region Common Event Properties
|
||||
|
||||
private string uniqueId;
|
||||
private string channel;
|
||||
private ManagerConnection src;
|
||||
protected Dictionary<string, string> attributes;
|
||||
|
||||
#region Constructors
|
||||
public ManagerEvent()
|
||||
{
|
||||
this.dateReceived = DateTime.Now;
|
||||
}
|
||||
|
||||
public ManagerEvent(ManagerConnection source)
|
||||
: this()
|
||||
{
|
||||
this.src = source as ManagerConnection;
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
#region Attributes
|
||||
/// <summary>
|
||||
/// Store all unknown (without setter) keys from manager event.<br/>
|
||||
/// Use in default Parse method <see cref="Parse(string key, string value)"/>.
|
||||
/// Use in default Parse method <see cref="ManagerEvent.Parse(string, string)"/>
|
||||
/// </summary>
|
||||
public Dictionary<string, string> Attributes
|
||||
{
|
||||
get { return attributes; }
|
||||
}
|
||||
#endregion
|
||||
public Dictionary<string, string> Attributes { get; set; }
|
||||
|
||||
#region Server
|
||||
/// <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.
|
||||
/// Get/Set the name of the channel.
|
||||
/// </summary>
|
||||
public string Server
|
||||
{
|
||||
get { return server; }
|
||||
set { server = value; }
|
||||
}
|
||||
#endregion
|
||||
public string Channel { get; set; }
|
||||
|
||||
#region Timestamp
|
||||
/// <summary>
|
||||
/// Returns the timestamp for this event.<br/>
|
||||
/// The timestamp property is available in Asterisk since 1.4
|
||||
/// if enabled in manager.conf by setting timestampevents = yes.
|
||||
/// In contains the time the event was generated in seconds since the epoch.
|
||||
/// </summary>
|
||||
public double Timestamp
|
||||
{
|
||||
get { return this.timestamp; }
|
||||
set { this.timestamp = value; }
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region DateReceived
|
||||
/// <summary>
|
||||
/// Get/Set the point in time this event was received from the Asterisk server.<br/>
|
||||
/// Pseudo events that are not directly received from the asterisk server
|
||||
/// (for example ConnectEvent and DisconnectEvent) may return null.
|
||||
/// </summary>
|
||||
public DateTime DateReceived
|
||||
{
|
||||
get { return this.dateReceived; }
|
||||
set { this.dateReceived = value; }
|
||||
}
|
||||
#endregion
|
||||
public DateTime DateReceived { get; set; }
|
||||
|
||||
#region Privilege
|
||||
/// <summary>
|
||||
/// Get/Set the AMI authorization class of this event.<br/>
|
||||
/// This is one or more of system, call, log, verbose, command, agent or user.
|
||||
/// Multiple privileges are separated by comma.<br/>
|
||||
/// Note: This property is not available from Asterisk 1.0 servers.
|
||||
/// </summary>
|
||||
public string Privilege
|
||||
{
|
||||
get { return privilege; }
|
||||
set { this.privilege = value; }
|
||||
}
|
||||
#endregion
|
||||
public string Privilege { get; set; }
|
||||
|
||||
#region Source
|
||||
/// <summary>
|
||||
/// Event source.
|
||||
/// 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 ManagerConnection Source
|
||||
{
|
||||
get { return this.src; }
|
||||
}
|
||||
#endregion
|
||||
public string Server { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The ManagerConnection the Event was sourced from.
|
||||
/// </summary>
|
||||
public ManagerConnection Source { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Returns the timestamp for this event.<br/>
|
||||
/// The timestamp property is available in Asterisk since 1.4
|
||||
/// if enabled in manager.conf by setting timestampevents = yes.
|
||||
/// In contains the time the event was generated in seconds since the epoch.
|
||||
/// </summary>
|
||||
public double Timestamp { get; set; }
|
||||
|
||||
#region UniqueId
|
||||
/// <summary>
|
||||
/// Get/Set the unique id of the channel.
|
||||
/// </summary>
|
||||
public string UniqueId
|
||||
{
|
||||
get { return uniqueId; }
|
||||
set { this.uniqueId = value; }
|
||||
}
|
||||
public string UniqueId { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
#region Channel
|
||||
#region Constructors
|
||||
/// <summary>
|
||||
/// Get/Set the name of the channel.
|
||||
/// Creates a new ManagerEvent. Source already set.
|
||||
/// </summary>
|
||||
public string Channel
|
||||
public ManagerEvent()
|
||||
{
|
||||
get { return channel; }
|
||||
set { this.channel = value; }
|
||||
this.DateReceived = DateTime.Now;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new ManagerEvent
|
||||
/// </summary>
|
||||
/// <param name="source">ManagerConnection passed through in the event.</param>
|
||||
public ManagerEvent(ManagerConnection source)
|
||||
: this()
|
||||
{
|
||||
this.Source = source;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Methods
|
||||
|
||||
#region Parse(string key, string value)
|
||||
/// <summary>
|
||||
/// Unknown properties parser
|
||||
/// </summary>
|
||||
|
@ -144,21 +99,25 @@ namespace AsterNET.Manager.Event
|
|||
/// <returns>true - value parsed, false - can't parse value</returns>
|
||||
public virtual bool Parse(string key, string value)
|
||||
{
|
||||
if (attributes == null)
|
||||
attributes = new Dictionary<string, string>();
|
||||
if (Attributes == null)
|
||||
{
|
||||
Attributes = new Dictionary<string, string>();
|
||||
}
|
||||
|
||||
if (attributes.ContainsKey(key))
|
||||
// Key already presents, add with delimiter
|
||||
attributes[key] += string.Concat(Common.LINE_SEPARATOR, value);
|
||||
if (Attributes.ContainsKey(key))
|
||||
{
|
||||
Attributes[key] += string.Concat(Common.LINE_SEPARATOR, value); // Key already presents, add with delimiter
|
||||
}
|
||||
else
|
||||
attributes.Add(key, value);
|
||||
{
|
||||
Attributes.Add(key, value);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region ParseSpecial(Dictionary<string, string> attributes)
|
||||
/// <summary>
|
||||
/// Unknown properties parser
|
||||
/// Unknown properties parser.
|
||||
/// </summary>
|
||||
/// <param name="attributes">dictionary</param>
|
||||
/// <returns>updated dictionary</returns>
|
||||
|
@ -166,9 +125,11 @@ namespace AsterNET.Manager.Event
|
|||
{
|
||||
return attributes;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region ToString()
|
||||
/// <summary>
|
||||
/// Convert all properties to string
|
||||
/// </summary>
|
||||
/// <returns>All event details and properties as a string</returns>
|
||||
public override string ToString()
|
||||
{
|
||||
return Helper.ToString(this);
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
namespace AsterNET.Manager.Event
|
||||
{
|
||||
/// <summary>
|
||||
/// A QueueCallerJoinEvent is triggered when a channel joins a queue.<br/>
|
||||
/// </summary>
|
||||
public class QueueCallerJoinEvent : QueueEvent
|
||||
{
|
||||
public string Position { get; set; }
|
||||
|
||||
public QueueCallerJoinEvent(ManagerConnection source)
|
||||
: base(source)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
namespace AsterNET.Manager.Event
|
||||
{
|
||||
/// <summary>
|
||||
/// A QueueCallerLeaveEvent is triggered when a channel leaves a queue.<br/>
|
||||
/// </summary>
|
||||
public class QueueCallerLeaveEvent : QueueEvent
|
||||
{
|
||||
public string Position { get; set; }
|
||||
|
||||
public QueueCallerLeaveEvent(ManagerConnection source)
|
||||
: base(source)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,45 @@
|
|||
using System;
|
||||
|
||||
namespace AsterNET.Manager.Event
|
||||
{
|
||||
/// <summary>
|
||||
/// Raised when a member is paused/unpaused in the queue.<br />
|
||||
/// Available since Asterisk 12
|
||||
/// </summary>
|
||||
public class QueueMemberPauseEvent : AbstractQueueMemberEvent
|
||||
{
|
||||
/// <summary>
|
||||
/// The name of the queue member.
|
||||
/// </summary>
|
||||
public string MemberName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Get/Set if this queue member is paused (not accepting calls).<br/>
|
||||
/// true if this member has been paused or
|
||||
/// false if not.
|
||||
/// </summary>
|
||||
public bool Paused { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The reason a member was paused.
|
||||
/// </summary>
|
||||
public string Reason { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Set to 1 if member is in call. Set to 0 after LastCall time is updated.<br/>
|
||||
/// Available since Asterisk 13
|
||||
/// </summary>
|
||||
public string InCall { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// If set when paused, the reason the queue member was paused.<br/>
|
||||
/// Available since Asterisk 13
|
||||
/// </summary>
|
||||
public string PausedReason { get; set; }
|
||||
|
||||
public QueueMemberPauseEvent(ManagerConnection source)
|
||||
: base(source)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,9 +1,15 @@
|
|||
using System;
|
||||
|
||||
namespace AsterNET.Manager.Event
|
||||
{
|
||||
/// <summary>
|
||||
/// A QueueMemberPausedEvent is triggered when a queue member is paused or unpaused.<br/>
|
||||
/// It is implemented in apps/app_queue.c.<br/>
|
||||
/// Available since Asterisk 1.2
|
||||
/// <para>
|
||||
/// Available since Asterisk 1.2.<br/>
|
||||
/// Replaced by <see cref="QueueMemberPauseEvent"/> since Asterisk 12.<br/>
|
||||
/// Removed since Asterisk 13.<br/>
|
||||
/// </para>
|
||||
/// </summary>
|
||||
public class QueueMemberPausedEvent : AbstractQueueMemberEvent
|
||||
{
|
||||
|
|
|
@ -95,6 +95,11 @@ namespace AsterNET.Manager
|
|||
public delegate void BridgeDestroyEventHandler(object sender, Event.BridgeDestroyEvent e);
|
||||
public delegate void BridgeEnterEventHandler(object sender, Event.BridgeEnterEvent e);
|
||||
public delegate void BridgeLeaveEventHandler(object sender, Event.BridgeLeaveEvent e);
|
||||
public delegate void DialBeginEventHandler(object sender, Event.DialBeginEvent e);
|
||||
public delegate void DialEndEventHandler(object sender, Event.DialEndEvent e);
|
||||
public delegate void QueueCallerJoinEventHandler(object sender, Event.QueueCallerJoinEvent e);
|
||||
public delegate void QueueCallerLeaveEventHandler(object sender, Event.QueueCallerLeaveEvent e);
|
||||
public delegate void QueueMemberPauseEventHandler(object sender, Event.QueueMemberPauseEvent e);
|
||||
|
||||
|
||||
|
||||
|
@ -486,6 +491,32 @@ namespace AsterNET.Manager
|
|||
public event BridgeEnterEventHandler BridgeEnter;
|
||||
public event BridgeLeaveEventHandler BridgeLeave;
|
||||
|
||||
/// <summary>
|
||||
/// Raised when a dial action has started.<br/>
|
||||
/// </summary>
|
||||
public event DialBeginEventHandler DialBegin;
|
||||
|
||||
/// <summary>
|
||||
/// Raised when a dial action has completed.<br/>
|
||||
/// </summary>
|
||||
public event DialEndEventHandler DialEnd;
|
||||
|
||||
/// <summary>
|
||||
/// Raised when a caller joins a Queue.<br/>
|
||||
/// </summary>
|
||||
public event QueueCallerJoinEventHandler QueueCallerJoin;
|
||||
|
||||
/// <summary>
|
||||
/// Raised when a caller leaves a Queue.<br/>
|
||||
/// </summary>
|
||||
public event QueueCallerLeaveEventHandler QueueCallerLeave;
|
||||
|
||||
/// <summary>
|
||||
/// A QueueMemberPauseEvent is triggered when a queue member is paused or unpaused.<br />
|
||||
/// Available since Asterisk 12
|
||||
/// </summary>
|
||||
public event QueueMemberPauseEventHandler QueueMemberPause;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructor - ManagerConnection()
|
||||
|
@ -595,7 +626,11 @@ namespace AsterNET.Manager
|
|||
Helper.RegisterEventHandler(registeredEventHandlers, 90, typeof(BridgeEnterEvent));
|
||||
Helper.RegisterEventHandler(registeredEventHandlers, 91, typeof(BridgeLeaveEvent));
|
||||
Helper.RegisterEventHandler(registeredEventHandlers, 92, typeof(BlindTransferEvent));
|
||||
|
||||
Helper.RegisterEventHandler(registeredEventHandlers, 93, typeof(DialBeginEvent));
|
||||
Helper.RegisterEventHandler(registeredEventHandlers, 94, typeof(DialEndEvent));
|
||||
Helper.RegisterEventHandler(registeredEventHandlers, 95, typeof(QueueCallerJoinEvent));
|
||||
Helper.RegisterEventHandler(registeredEventHandlers, 96, typeof(QueueCallerLeaveEvent));
|
||||
Helper.RegisterEventHandler(registeredEventHandlers, 97, typeof(QueueMemberPauseEvent));
|
||||
|
||||
#endregion
|
||||
|
||||
|
@ -1214,6 +1249,36 @@ namespace AsterNET.Manager
|
|||
BlindTransfer(this, (BlindTransferEvent)e);
|
||||
}
|
||||
break;
|
||||
case 93:
|
||||
if (DialBegin != null)
|
||||
{
|
||||
DialBegin(this, (DialBeginEvent)e);
|
||||
}
|
||||
break;
|
||||
case 94:
|
||||
if (DialEnd != null)
|
||||
{
|
||||
DialEnd(this, (DialEndEvent)e);
|
||||
}
|
||||
break;
|
||||
case 95:
|
||||
if (QueueCallerJoin != null)
|
||||
{
|
||||
QueueCallerJoin(this, (QueueCallerJoinEvent)e);
|
||||
}
|
||||
break;
|
||||
case 96:
|
||||
if (QueueCallerLeave != null)
|
||||
{
|
||||
QueueCallerLeave(this, (QueueCallerLeaveEvent)e);
|
||||
}
|
||||
break;
|
||||
case 97:
|
||||
if (QueueMemberPause != null)
|
||||
{
|
||||
QueueMemberPause(this, (QueueMemberPauseEvent)e);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
if (UnhandledEvent != null)
|
||||
UnhandledEvent(this, e);
|
||||
|
|
|
@ -1,3 +1,9 @@
|
|||
21.09.2016 (herman1vdb)
|
||||
Added events DialEndEvent, QueueCallerJoinEvent, QueueCallerLeaveEvent for further Asterisk 13 support
|
||||
|
||||
20.09.2016 (herman1vdb)
|
||||
Added DialBeginEvent
|
||||
|
||||
05.01.2015 (Skrusty)
|
||||
Added a sandcastle documentation project to AsterNET. Initial draft includes CHM and HTML output based on AsterNET 1.0.0.
|
||||
|
||||
|
|
Loading…
Reference in a new issue