我需要使用
AsterNET.ARI
Asterisk ARI 从号码 401 拨打至 402(401 和 402 是连接到软件电话的两个内部号码)
我的扩展.conf
exten => 1000,1, NoOp()
same => n,Stasis(originate-example)
same => n,Hangup()
c#
using AsterNET.ARI;
using AsterNET.ARI.Helpers;
using AsterNET.ARI.Models;
var AppName = "originate-example";
var actionClient = new AriClient(new StasisEndpoint("127.0.0.1", 8088, "asterisk", "asterisk"), AppName);
actionClient.Connect();
//I subscribe to the application start event
actionClient.OnStasisStartEvent += ActionClientOnOnStasisStartEvent;
void ActionClientOnOnStasisStartEvent(IAriClient sender, StasisStartEvent e)
{
//answer the call
actionClient.Channels.Answer(e.Channel.Id);
//sound file is playing
SyncHelper.Wait(actionClient.Channels.Play(e.Channel.Id, "sound:vm-dialout", "en", 0, 0, Guid.NewGuid().ToString()), actionClient);
//I'm trying to call from 401 number to 402 but the call doesn't happen
actionClient.Channels.Originate(
endpoint:"PJSIP/401", //the number from which I called 1000 to start stasis
extension:"402", //the number I'm calling
callerId:"401",
timeout:100000 ,
app:AppName,
priority: 1
);
}
Console.ReadLine();
库的描述说,当
Channels.Originate
运行时会自动创建桥,但没有进行调用。我在库文档中找不到有关如何实现简单调用的示例。
对于内部号码之间的简单呼叫,您必须使用 dialplan 和 Dial 命令。
以防万一互联网出现故障或您的应用程序出现故障。
如果您仍然想通过 .net 进行操作 - 使用 context 而不是 application 作为第二个参数(很可能您还想使用 Local/EXTEN@context 而不是 pjsip 作为第一个参数)。
ps 您显示的是另一个不相关的呼叫,拨打 1000 分机。