我正在使用C#/。NET library 来实施Asterisk RESTful Interface (ARI)来创建电话会议应用。
到目前为止,应用程序的工作原理如下:
要求:
在将用户添加到会议之前,我需要在上述过程中添加某种授权。我需要实施询问PIN码功能,创建PIN号码构造,如果来电者输入正确的PIN码,则将来电者添加到正确的电话会议中。
守则:
会议
public Conference( AriClient c, Guid id, string name)
{
_client = c;
Id = id;
ConferenceName = name;
State = ConferenceState.Destroyed;
c.OnChannelDtmfReceivedEvent += c_OnChannelDtmfReceivedEvent; // ??
c.OnBridgeCreatedEvent += c_OnBridgeCreatedEvent;
c.OnChannelEnteredBridgeEvent += c_OnChannelEnteredBridgeEvent;
c.OnBridgeDestroyedEvent += c_OnBridgeDestroyedEvent;
c.OnChannelLeftBridgeEvent += c_OnChannelLeftBridgeEvent;
c.OnRecordingFinishedEvent += c_OnRecordingFinishedEvent;
// Added support for talk detection
c.OnChannelTalkingStartedEvent += c_OnChannelTalkingStartedEvent;
c.OnChannelTalkingFinishedEvent += c_OnChannelTalkingFinishedEvent;
Debug.Print("Added Conference {0}", ConferenceName);
}
OnChannelEnteredBridgeEvent:
private void c_OnChannelEnteredBridgeEvent(object sender, ChannelEnteredBridgeEvent e)
{
ConferenceUser confUser = ConferenceUsers.SingleOrDefault(x => x.Channel.Id == e.Channel.Id);
if (confUser == null) return;
confUser.State = ConferenceUserState.InConf;
if (ConferenceUsers.Count(x => x.State == ConferenceUserState.InConf) > 1) // are we the only ones here
{
// stop moh
_client.Bridges.StopMoh(Confbridge.Id);
// change state
State = ConferenceState.Ready;
// announce new user
_client.Bridges.Play(Confbridge.Id, "recording:" + confUser.CurrentRecodingId, "en", 0, 0, Guid.NewGuid().ToString());
_client.Bridges.Play(Confbridge.Id, "sound:conf-hasjoin", "en", 0, 0, Guid.NewGuid().ToString());
}
else
{
// only caller in conf
_client.Channels.Play(e.Channel.Id, "sound:conf-onlyperson", "en", 0, 0, Guid.NewGuid().ToString());
}
}
StartConference:
public bool StartConference()
{
// Create the conference bridge
Debug.Print("Requesting new bridge {0} for {1}", Id, ConferenceName);
Bridge bridge = _client.Bridges.Create("mixing", Id.ToString(), ConferenceName);
if (bridge == null)
{
return false;
}
Debug.Print("Subscribing to events on bridge {0} for {1}", Id, ConferenceName);
_client.Applications.Subscribe(AppConfig.AppName, "bridge:" + bridge.Id);
// Start MOH on conf bridge
_client.Bridges.StartMoh(bridge.Id, "default");
// Default state is ReadyWaiting until MOH is turned off
State = ConferenceState.ReadyWaiting;
Confbridge = bridge;
// Conference ready to accept calls
State = ConferenceState.Ready;
return true;
}
ADDUSER:
public bool AddUser(Channel c) //here check for pin and caller id
{
if (State == ConferenceState.Destroying)
return false;
if (State == ConferenceState.Destroyed)
{
// We should initiate a new conference bridge
if (!StartConference())
return false;
}
if (State < ConferenceState.Ready) return false;
// Answer channel
_client.Channels.Answer(c.Id);
// Turn on talk detection on this channel
_client.Channels.SetChannelVar(c.Id, "TALK_DETECT(set)", "");
// Add conference user to collection
ConferenceUsers.Add(new ConferenceUser(this, c, _client, ConferenceUserType.Normal));
return true;
}
问题:
如何提出/调用&#34;询问引脚号&#34;应用程序中的事件/频道并将输入的DTMF数字抓取到变量中?
这可以仅在我的C#ARI应用程序中完成,还是我需要在Asterisk服务器上摆弄.conf文件?
我首选的方法是在我的C#ARI应用程序中实现它,因为这可以让我更好地控制会议。
答案 0 :(得分:-2)
你应该创建一些拨号方案来支持它,并要求拨号方案检查你的插针等
当然可以在没有拨号方案支持的情况下完成,但在这种情况下,任务成为大师级别,没有真正意义上的那样。
首先,我可以向您推荐“Asterisk the telephony”一书。
您可以使用func_odbc,读取应用程序,CHANNEL函数(用于ip)