示例#1
0
        public override void onIncomingCall(OnIncomingCallParam prm)
        {
            CallOpParam cprm = new CallOpParam();

            cprm.statusCode = pjsip_status_code.PJSIP_SC_RINGING;
            PjsipCall call = new PjsipCall(this, prm.callId);

            call.answer(cprm);

            if (onAccountIncomingCall != null)
            {
                onAccountIncomingCall(this, call, prm.callId);
            }
        }
示例#2
0
 /// <summary>
 /// Вызов на набранный номер
 /// </summary>
 private void MakeCall()
 {
     try
     {
         CallOpParam prm = new CallOpParam(true);
         currentCall = new PjsipCall(checkedAccount);
         string destUri = string.Format("sip:{0}@{1}", tbNumber.Text.Trim(), checkedAccount.Host);
         currentCall.makeCall(destUri, prm);
         currentCall.OnCallDisconnected = CallDisconnect;
         SetCallButtonState(CallButtonState.Hungup);
     }
     catch
     {
         Hungup();
     }
 }
示例#3
0
 /// <summary>
 /// Обработка разрыва соединения
 /// </summary>
 /// <param name="call"></param>
 private void CallDisconnect(PjsipCall call)
 {
     if (InvokeRequired)
     {
         CallDisconnected cd = new CallDisconnected(CallDisconnect);
         Invoke(cd, new object[] { call });
     }
     else
     {
         currentCall.Dispose();
         currentCall = null;
         SetCallButtonState(string.IsNullOrWhiteSpace(tbNumber.Text) ?
                            CallButtonState.Disable : CallButtonState.Call);
         if (ring != null)
         {
             ring.Stop = true;
             ring      = null;
         }
     }
 }
示例#4
0
 /// <summary>
 /// Обработка входящего вызова
 /// </summary>
 /// <param name="acc"></param>
 /// <param name="callId"></param>
 private void IncomingCall(PjsipAccount acc, PjsipCall call, int callId)
 {
     if (InvokeRequired)
     {
         AccountIncomingCall ic = new AccountIncomingCall(IncomingCall);
         Invoke(ic, new object[] { acc, call, callId });
     }
     else
     {
         try
         {
             if (currentCall != null && currentCall.IsOnline)
             {
                 CallOpParam prm = new CallOpParam();
                 prm.statusCode = pjsip_status_code.PJSIP_SC_BUSY_HERE;
                 call.answer(prm);
                 call.Dispose();
             }
             else
             {
                 SelectAccount(acc);
                 currentCall = call;
                 currentCall.OnCallIncoming     = CallIncomingInfo;
                 currentCall.OnCallDisconnected = CallDisconnect;
                 SetCallButtonState(CallButtonState.Ring);
                 ring = new PjsipRing();
             }
         }
         catch
         {
             if (currentCall != null)
             {
                 Hungup();
             }
         }
     }
 }