private void OnIncomingAudioVideoCallReceived(object sender, CallReceivedEventArgs<AudioVideoCall> e) { // Build a list with the authorized URIs. List<string> authorizedSipUris = new List<string>() { "sip:[email protected]", "sip:[email protected]" }; if (authorizedSipUris.Contains(e.RemoteParticipant.Uri)) { _logger.Log("Call is from an authorized URI. Accepting."); AcceptCall(e.Call); } else { _logger.Log("Call is not from an authorized URI. Declining."); CallDeclineOptions options = new CallDeclineOptions() { ResponseCode = ResponseCode.Forbidden }; e.Call.Decline(options); } }
private void ReceiveIncomingIMCall(object sender, CallReceivedEventArgs <InstantMessagingCall> e) { this.Logger.Log(Logger.LogLevel.Verbose, string.Format( CultureInfo.InvariantCulture, "IMCall {0} received.", Logger.Pointer(e.Call))); if (this.IsTerminatingTerminated || e.IsConferenceDialOut) { var declineOptions = new CallDeclineOptions(); declineOptions.ResponseCode = ResponseCode.RequestTerminated; this.RejectCall(e.Call, declineOptions); return; } ConversationParticipant caller = e.Call.RemoteEndpoint.Participant; RealTimeAddress uriAddress = new RealTimeAddress(caller.Uri); if (!uriAddress.IsPhone && e.Call.RemoteEndpoint.Participant.SourceNetwork == SourceNetwork.SameEnterprise) { System.Threading.ThreadPool.QueueUserWorkItem(this.HandleIMCall, e); } else { var declineOptions = new CallDeclineOptions(); declineOptions.ResponseCode = ResponseCode.RequestTerminated; this.RejectCall(e.Call, declineOptions); return; } }
private void RejectCall(Call call, CallDeclineOptions options) { this.Logger.Log(Logger.LogLevel.Info, string.Format(CultureInfo.InvariantCulture, "Rejecting the call {0}.", Logger.Pointer(call))); try { call.Decline(options); } catch (InvalidOperationException ioe) { this.Logger.Log(Logger.LogLevel.Info, ioe); // This can happen if the call was cancelled by now. } catch (RealTimeException rte) { this.Logger.Log(Logger.LogLevel.Error, rte); } }
private void ReceiveIncomingAvCall(object sender, CallReceivedEventArgs <AudioVideoCall> e) { this.Logger.Log(Logger.LogLevel.Verbose, string.Format( CultureInfo.InvariantCulture, "AvCall {0} received.", Logger.Pointer(e.Call))); if (this.IsTerminatingTerminated || e.IsConferenceDialOut) { var declineOptions = new CallDeclineOptions(); declineOptions.ResponseCode = ResponseCode.RequestTerminated; this.RejectCall(e.Call, declineOptions); return; } this.StartupCustomerSession(e.Call); }