我一直在使用WinForms构建一个使用C#的桌面应用程序,该应用程序使用Aster.NET (以前是Asterisk.NET的分叉)与星号接口。我们在可靠地识别和跟踪与单个扩展/用户相关的呼叫时遇到了真正的困难。
我们遇到的问题是由于星号引发/触发的事件具有不可预知/模糊的性质,这些事件是巨大的变量,这取决于调用在到达扩展之前的路由方式。
例如,事件序列/格式在以下情况下是不同的:一个呼叫在被盲传输之前击中了一个IVR;如果一个呼叫在被传送之前击中了一个IVR;如果一个呼叫直接转到用户的分机上。
使用不同的唯一ID (例如,呼叫的传入侧具有与呼叫的接收侧不同的UID )的星号跟踪呼叫的每一方的方式进一步阻碍了这一点。虽然我们已经设法在(随后丑陋的)中解释了这一点!代码中,我们仍然遇到了计算调用可能采用的不同路由路径的问题。
因此,我寻求关于我们如何做以下工作的任何建议:
目前,我们有一个极其复杂的事件处理程序链,它们根据应用程序的“当前状态”进行不同的操作。
举一个例子:如果我们检测到NewStateEvent的ChannelState为6 ('Up'),我们将检查进程中是否有一个正在进行的调用,并且UID是否匹配,如果匹配,那么当前的调用已经被响应。如果UID不匹配,但其他因素匹配(例如通道、connectedlinenum等),那么我们将其作为呼叫的“另一方”(即接收方或传入方)。
我不确定问题是在于API还是AMI --但无论是哪种问题,都会给我们带来一些真正的麻烦。
任何建议都非常感谢。
发布于 2014-02-01 06:08:47
你能更新到星号12吗?AMI中的通道名现在稳定在星号12中。
https://wiki.asterisk.org/wiki/display/AST/AMI+v2+Specification
发布于 2019-09-23 06:10:51
我正在使用c#中的package c#。首先安装最新的aster.net软件包
比检查代码.this代码更适合我。
manager = new ManagerConnection(address, port, user, password);
manager.UnhandledEvent += new ManagerEventHandler(manager_Events);
manager.NewState += new NewStateEventHandler(Monitoring_NewState);
try
{
// Uncomment next 2 line comments to Disable timeout (debug mode)
// manager.DefaultResponseTimeout = 0;
// manager.DefaultEventTimeout = 0;
manager.Login();
if (manager.IsConnected())
{
Console.WriteLine("user name : " + manager.Username);
Console.ReadLine();
}
}
catch (Exception ex)
{
Console.WriteLine("Error connect\n" + ex.Message);
manager.Logoff();
Console.ReadLine();
}
void manager_Events(object sender, ManagerEvent e)
{
Console.WriteLine("Event : " + e.GetType().Name);
}
void Monitoring_NewState(object sender, NewStateEvent e)
{
string state = e.State;
string callerID = e.CallerId;
Console.WriteLine("caller num ...", e.CallerIdNum);
//Console.WriteLine("state =", state);
//Console.WriteLine("callerID =", callerID);
if ((state == "Ringing") | (e.ChannelState == "5"))
{
Console.WriteLine("hello rining your phone now ...");
String connectedLineNum;
String connectedLineName;
Dictionary<String, String> attributes = e.Attributes;
attributes.TryGetValue("connectedlinenum", out connectedLineNum);
attributes.TryGetValue("connectedlinename", out connectedLineName);
// "callerID" - called phone number
// "connectedLineNum" - calling phone number
// CallIn. Incoming call
}
else if ((state == "Ring") | (e.ChannelState == "4"))
{
Console.WriteLine("hello out going your call ...");
// CallOut. Outcoming call
}
else if ((state == "Up") | (e.ChannelState == "6"))
{
String connectedLineNum;
String connectedLineName;
Dictionary<String, String> attributes = e.Attributes;
attributes.TryGetValue("connectedlinenum", out connectedLineNum);
attributes.TryGetValue("connectedlinename", out connectedLineName);
// "callerID" - called phone number
// "connectedLineNum" - calling phone number
// human lifted up the phone right no
Console.WriteLine("human lifted up the phone...");
}
}https://stackoverflow.com/questions/21459508
复制相似问题