SIPUserAgent objSIPUserAgent = new SIPUserAgent();
WindowsAudioEndPoint objWindowsAudioEndPoint = new WindowsAudioEndPoint(new AudioEncoder());
VoIPMediaSession objVoIPMediaSession = new VoIPMediaSession(objWindowsAudioEndPoint.ToMediaEndPoints());
objVoIPMediaSession.AcceptRtpFromAny = true;
string strDestinationAddress = strDialledNumber + gblStrDomain;
bool blnCallResult = await objSIPUserAgent.Call(strDestinationAddress, gblStrExtentionNumber, gblStrExtentionPassword, objVoIPMediaSession);
- 服务器正在使用上面的代码片段调用接收器。
- 来电通知接收方
在这种情况下,我有两个问题。
- 服务器如何拒绝/取消呼出?
- 接收方如何检测到呼叫被服务器拒绝/取消?
bool result = objSIPUserAgent.HangUp();
可用于拒绝或取消呼出呼叫。
和下面,我们可以订阅事件OnCallRejected触发调用被拒绝通过服务器
objSIPUserAgent.OnCallRejected += (sender, args) => {
};
也可以OnCallTerminated事件。当调用被取消时触发
objSIPUserAgent.OnCallTerminated += (sender, args) => {
if (args.Reason == CallTerminationReason.LocalCanceled) {
// Handle call canceled event here
}
};
希望对你有帮助。
OnCallRejected和OnCallTerminated事件在6.0.12版本的库中不可用。这些事件是在较晚的版本中添加的,特别是版本7.0.0
对于旧版本,
objSIPUserAgent.CallHungup += (uas, reason, lastResponse) =>
{
if (reason == SIPCallTerminateReasonsEnum.None)
{
// The call was terminated normally.
Console.WriteLine("Call Terminated.");
}
else if (reason ==
SIPCallTerminateReasonsEnum.RemoteCancel) {
Console.WriteLine("Cancelled by remote party")
}
};