/// <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; } } }
/// <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(); } } } }