public void RaiseIncomingCall() { Check.Require(PendingInvite, "PendingInvite"); var from = PendingInvite.OriginalRequest.From.SipUri; _pendingPhoneCall = new PhoneCall(this, true, from, new Command(OnPhoneCallAccepted), new Command(OnPhoneCallRejected), new Command(OnPhoneCallStopped)); IncomingCall(this, new VoipEventArgs <IPhoneCall>(_pendingPhoneCall)); }
private void OnPhoneCallStarted(IInternalPhoneCall phoneCall) { Check.Require(phoneCall, "phoneCall"); Check.IsTrue(InternalState == _stateProvider.GetIdle(), string.Format("Failed to start the call. The phone can only start calls while in 'IDLE' state. CurrentState: '{0}'", CurrentState)); Check.IsTrue(_isRunning, "Failed to start the call. The phone must be started first."); _pendingPhoneCall = phoneCall; if (_logger.IsInfoEnabled) { _logger.Info("Starting new phonecall..."); } if (_logger.IsDebugEnabled) { _logger.Debug("Creating 'INVITE' request..."); } var thisUri = AddressFactory.CreateUri(string.Empty, ListeningPoint.ToString()); var requestUri = phoneCall.GetToUri(); var toAddress = AddressFactory.CreateAddress(string.Empty, phoneCall.GetToUri()); var fromAddress = AddressFactory.CreateAddress(string.Empty, thisUri); var toHeader = HeaderFactory.CreateToHeader(toAddress); var fromHeader = HeaderFactory.CreateFromHeader(fromAddress, SipUtil.CreateTag()); var cseqHeader = HeaderFactory.CreateSCeqHeader(SipMethods.Invite, MessageCounter++); var callIdheader = HeaderFactory.CreateCallIdHeader(SipUtil.CreateCallId()); var viaHeader = HeaderFactory.CreateViaHeader(ListeningPoint.Address, ListeningPoint.Port, SipConstants.Udp, SipUtil.CreateBranch()); var maxForwardsHeader = HeaderFactory.CreateMaxForwardsHeader(1); var request = MessageFactory.CreateRequest( requestUri, SipMethods.Invite, callIdheader, cseqHeader, fromHeader, toHeader, viaHeader, maxForwardsHeader); /*add contactheader*/ var contactUri = AddressFactory.CreateUri(thisUri.User, viaHeader.SentBy.ToString()); var contactHeader = HeaderFactory.CreateContactHeader(contactUri); request.Contacts.Add(contactHeader); if (_logger.IsDebugEnabled) { _logger.Debug("'INVITE' request created. Sending to callee.."); } var clientTransaction = SipProvider.CreateClientTransaction(request); var dialog = SipProvider.CreateClientDialog(clientTransaction as SipInviteClientTransaction); clientTransaction.SendRequest(); if (_logger.IsDebugEnabled) { _logger.Debug("'INVITE' sent."); } if (_logger.IsInfoEnabled) { _logger.Info("Request sent. Transitioning to 'WAITPROVISIONAL' state..."); } PendingInvite = new InviteInfo() { OriginalRequest = request, From = request.From.SipUri, To = request.To.SipUri, InviteClientTransaction = (SipInviteClientTransaction)clientTransaction, IsIncomingCall = false, Dialog = dialog }; ChangeState(_stateProvider.GetWaitProvisional()); }
private void OnPhoneCallStarted(IInternalPhoneCall phoneCall) { Check.Require(phoneCall, "phoneCall"); Check.IsTrue(InternalState == _stateProvider.GetIdle(), string.Format("Failed to start the call. The phone can only start calls while in 'IDLE' state. CurrentState: '{0}'", CurrentState)); Check.IsTrue(_isRunning, "Failed to start the call. The phone must be started first."); _pendingPhoneCall = phoneCall; if (_logger.IsInfoEnabled) _logger.Info("Starting new phonecall..."); if (_logger.IsDebugEnabled) _logger.Debug("Creating 'INVITE' request..."); var thisUri = AddressFactory.CreateUri(string.Empty, ListeningPoint.ToString()); var requestUri = phoneCall.GetToUri(); var toAddress = AddressFactory.CreateAddress(string.Empty, phoneCall.GetToUri()); var fromAddress = AddressFactory.CreateAddress(string.Empty, thisUri); var toHeader = HeaderFactory.CreateToHeader(toAddress); var fromHeader = HeaderFactory.CreateFromHeader(fromAddress, SipUtil.CreateTag()); var cseqHeader = HeaderFactory.CreateSCeqHeader(SipMethods.Invite, MessageCounter++); var callIdheader = HeaderFactory.CreateCallIdHeader(SipUtil.CreateCallId()); var viaHeader = HeaderFactory.CreateViaHeader(ListeningPoint.Address, ListeningPoint.Port, SipConstants.Udp, SipUtil.CreateBranch()); var maxForwardsHeader = HeaderFactory.CreateMaxForwardsHeader(1); var request = MessageFactory.CreateRequest( requestUri, SipMethods.Invite, callIdheader, cseqHeader, fromHeader, toHeader, viaHeader, maxForwardsHeader); /*add contactheader*/ var contactUri = AddressFactory.CreateUri(thisUri.User, viaHeader.SentBy.ToString()); var contactHeader = HeaderFactory.CreateContactHeader(contactUri); request.Contacts.Add(contactHeader); if (_logger.IsDebugEnabled) _logger.Debug("'INVITE' request created. Sending to callee.."); var clientTransaction = SipProvider.CreateClientTransaction(request); var dialog = SipProvider.CreateClientDialog(clientTransaction as SipInviteClientTransaction); clientTransaction.SendRequest(); if (_logger.IsDebugEnabled) _logger.Debug("'INVITE' sent."); if (_logger.IsInfoEnabled) _logger.Info("Request sent. Transitioning to 'WAITPROVISIONAL' state..."); PendingInvite = new InviteInfo() { OriginalRequest = request, From = request.From.SipUri, To = request.To.SipUri, InviteClientTransaction = (SipInviteClientTransaction)clientTransaction, IsIncomingCall = false, Dialog = dialog }; ChangeState(_stateProvider.GetWaitProvisional()); }
public void RaiseIncomingCall() { Check.Require(PendingInvite, "PendingInvite"); var from = PendingInvite.OriginalRequest.From.SipUri; _pendingPhoneCall = new PhoneCall(this, true, from, new Command(OnPhoneCallAccepted), new Command(OnPhoneCallRejected), new Command(OnPhoneCallStopped)); IncomingCall(this, new VoipEventArgs<IPhoneCall>(_pendingPhoneCall)); }