Example #1
0
        /// <summary>
        /// Call someone
        /// </summary>
        /// <param name="contact"></param>
        public void MakeCall(Contact contact)
        {
            IRequest           request     = _stack.CreateRequest("INVITE", _contact, contact);
            IClientTransaction transaction = _stack.CreateClientTransaction(request);

            transaction.ResponseReceived += OnInviteResponse;
        }
Example #2
0
        public Call Call(Contact from, Contact to)
        {
            IRequest           request     = _stack.CreateRequest(SipMethod.INVITE, from, to);
            IClientTransaction transaction = _stack.Send(request);

            transaction.ResponseReceived += OnResponse;
            transaction.TimedOut         += OnTimeout;
            transaction.TransportFailed  += OnTransportFailed;
            transaction.Terminated       += OnTerminate;

            var call = new Call
            {
                Destination = new CallParty {
                    Contact = to
                },
                Caller = new CallParty {
                    Contact = from
                },
                Id     = request.CallId,
                Reason = CallReasons.Direct,
                State  = CallState.Proceeding
            };

            _calls.Add(call.Id, call);
            CallChanged(this, new CallEventArgs(call));
            return(call);
        }
Example #3
0
        /// <summary>
        /// RFC3261 Section 8.1.3.5 Processing 4xx Responses
        /// </summary>
        /// <param name="response"></param>
        /// <returns></returns>
        private bool Process4xx(IClientTransaction transaction, IResponse response)
        {
            if (!StatusCodeHelper.Is4xx(response))
            {
                return(true);
            }

            // Certain 4xx response codes require specific UA processing,
            // independent of the method.

            // If a 401 (Unauthorized) or 407 (Proxy Authentication Required)
            // response is received, the UAC SHOULD follow the authorization
            // procedures of Section 22.2 and Section 22.3 to retry the request with
            // credentials.
            if (response.StatusCode == StatusCode.Unauthorized)
            {
                var request      = (IRequest)transaction.Request.Clone();
                var authenticate = (Authenticate)response.Headers[Authenticate.WWW_NAME];

                var authorization = new Authorization();
                authorization.Nonce = authenticate.Nonce;
            }

            // If a 413 (Request Entity Too Large) response is received (Section
            // 21.4.11), the request contained a body that was longer than the UAS
            // was willing to accept.  If possible, the UAC SHOULD retry the
            // request, either omitting the body or using one of a smaller length.


            // If a 415 (Unsupported Media Type) response is received (Section
            // 21.4.13), the request contained media types not supported by the UAS.
            // The UAC SHOULD retry sending the request, this time only using
            // content with types listed in the Accept header field in the response,
            // with encodings listed in the Accept-Encoding header field in the
            // response, and with languages listed in the Accept-Language in the
            // response.

            // If a 416 (Unsupported URI Scheme) response is received (Section
            // 21.4.14), the Request-URI used a URI scheme not supported by the
            // server.  The client SHOULD retry the request, this time, using a SIP
            // URI.

            // If a 420 (Bad Extension) response is received (Section 21.4.15), the
            // request contained a Require or Proxy-Require header field listing an
            // option-tag for a feature not supported by a proxy or UAS.  The UAC
            // SHOULD retry the request, this time omitting any extensions listed in
            // the Unsupported header field in the response.

            // In all of the above cases, the request is retried by creating a new
            // request with the appropriate modifications.  This new request
            // constitutes a new transaction and SHOULD have the same value of the
            // Call-ID, To, and From of the previous request, but the CSeq should
            // contain a new sequence number that is one higher than the previous.

            // With other 4xx responses, including those yet to be defined, a retry
            // may or may not be possible depending on the method and the use case.
            _logger.Warning("Failed to handle status code: " + response);
            return(false);
        }
Example #4
0
        public void Send(IRequest request)
        {
            IClientTransaction transaction = _stack.CreateClientTransaction(request);

            transaction.Terminated       += OnTransactionTerminated;
            transaction.TransportFailed  += OnTransportFailed;
            transaction.ResponseReceived += OnInviteResponse;
            _stack.Send(request);
        }
 public BankTransactionMenager(IClientTransaction client)
 {
     _clientTransactions = new List<IClientTransaction>();
     ClientTransactions.Add(client);
 }
Example #6
0
 public BankTransactionMenager(IClientTransaction client)
 {
     _clientTransactions = new List <IClientTransaction>();
     ClientTransactions.Add(client);
 }
Example #7
0
        /// <summary>
        /// RFC3261 Section 8.1.3.5 Processing 4xx Responses
        /// </summary>
        /// <param name="response"></param>
        /// <returns></returns>
        private bool Process4xx(IClientTransaction transaction, IResponse response)
        {
            if (!StatusCodeHelper.Is4xx(response))
                return true;

            // Certain 4xx response codes require specific UA processing,
            // independent of the method.

            // If a 401 (Unauthorized) or 407 (Proxy Authentication Required)
            // response is received, the UAC SHOULD follow the authorization
            // procedures of Section 22.2 and Section 22.3 to retry the request with
            // credentials.
            if (response.StatusCode == StatusCode.Unauthorized)
            {
                var request = (IRequest) transaction.Request.Clone();
                var authenticate = (Authenticate) response.Headers[Authenticate.WWW_NAME];

                var authorization = new Authorization();
                authorization.Nonce = authenticate.Nonce;
            }

            // If a 413 (Request Entity Too Large) response is received (Section
            // 21.4.11), the request contained a body that was longer than the UAS
            // was willing to accept.  If possible, the UAC SHOULD retry the
            // request, either omitting the body or using one of a smaller length.

            // If a 415 (Unsupported Media Type) response is received (Section
            // 21.4.13), the request contained media types not supported by the UAS.
            // The UAC SHOULD retry sending the request, this time only using
            // content with types listed in the Accept header field in the response,
            // with encodings listed in the Accept-Encoding header field in the
            // response, and with languages listed in the Accept-Language in the
            // response.

            // If a 416 (Unsupported URI Scheme) response is received (Section
            // 21.4.14), the Request-URI used a URI scheme not supported by the
            // server.  The client SHOULD retry the request, this time, using a SIP
            // URI.

            // If a 420 (Bad Extension) response is received (Section 21.4.15), the
            // request contained a Require or Proxy-Require header field listing an
            // option-tag for a feature not supported by a proxy or UAS.  The UAC
            // SHOULD retry the request, this time omitting any extensions listed in
            // the Unsupported header field in the response.

            // In all of the above cases, the request is retried by creating a new
            // request with the appropriate modifications.  This new request
            // constitutes a new transaction and SHOULD have the same value of the
            // Call-ID, To, and From of the previous request, but the CSeq should
            // contain a new sequence number that is one higher than the previous.

            // With other 4xx responses, including those yet to be defined, a retry
            // may or may not be possible depending on the method and the use case.
            _logger.Warning("Failed to handle status code: " + response);
            return false;
        }