Exemple #1
0
        //---------------------------------------------------------------------
        // Event handling methods called by SipClientTransaction.

        /// <summary>
        /// Handles messages received by a transport to be processed by this agent.
        /// </summary>
        /// <param name="transport">The source transport.</param>
        /// <param name="message">The received message.</param>
        public void OnReceive(ISipTransport transport, SipMessage message)
        {
            SipResponse          response = (SipResponse)message;
            SipClientTransaction transaction;
            string transactionID;

            if (response == null)
            {
                return;     // Ignore any requests
            }
            // Route the message to the correct transaction.

            if (!response.TryGetTransactionID(out transactionID))
            {
                return;
            }

            using (TimedLock.Lock(this))
            {
                if (!transactions.TryGetValue(transactionID, out transaction))
                {
                    // The response doesn't map to an existing transaction.
                    // We're going to pass this to the core's OnUncorrelatedResponse()
                    // method.

                    core.OnUncorrelatedResponse(this, response);
                    return;
                }
            }

            transaction.OnResponse(transport, response);
        }