我正在使用Ozeki.VoIP.SDK我们的 Elastix 系统中处理传入的 VoIP 呼叫。我要做的是在我的应用程序中读取和显示有关来电的信息,并让桌面电话也响铃。
问题是,当我将电话线路从 VoIP 池注册到 Ozeki 控制器时,该线路的来电将不再在我的桌面电话上响铃。但是,当我取消注册该电话线时,我的桌面电话在接到电话时会再次响铃。
我不知道为什么 Ozeki SDK 会阻止我在应用程序中读取的调用。
private ISoftPhone _softphone;
private Dictionary<string,IPhoneLine> _phoneLines;
public Softphone()
{
_softphone = SoftPhoneFactory.CreateSoftPhone(IP_ADDRESS, MIN_PORT, MAX_PORT, SIP_PORT);
_softphone.ChangeNATSettings(Ozeki.Network.Nat.NATTraversalMethodType.NONE, "", "", "");
_softphone.IncommingCall += softphone_IncommingCall;
_phoneLines = new Dictionary<string, IPhoneLine>();
}
public bool IsRegistered(string username)
{
return (_phoneLines.Keys.Contains(username));
}
public void Register(SIPAccount account)
{
if (IsRegistered(account.UserName))
{
Unregister(account);
Thread.Sleep(1000);
}
//throw new Exception(string.Format("The account with username={0} already registered.", account.UserName));
// With the SIP account and the NAT configuration, we can create a phoneline.
IPhoneLine phoneLine = _softphone.CreatePhoneLine(account);
// If our phoneline is created, we can register that.
_softphone.RegisterPhoneLine(phoneLine);
_phoneLines.Add(account.UserName, phoneLine);
}
public void Unregister(SIPAccount account)
{
IPhoneLine phoneLine = _softphone.CreatePhoneLine(account);
_phoneLines.Remove(account.UserName);
_softphone.UnregisterPhoneLine(phoneLine);
}
private void DispatchAsync(Action action)
{
var task = new WaitCallback(o => action.Invoke());
ThreadPool.QueueUserWorkItem(task);
}
private void softphone_IncommingCall(object sender, VoIPEventArgs<IPhoneCall> e)
{
DispatchAsync(() =>
{
onIncomingCall(e);
});
}
private void onIncomingCall(VoIPEventArgs<IPhoneCall> e)
{
if (IncomingCall != null)
IncomingCall(this, e);
}
有没有人见过这种行为?我没有线索。