Beispiel #1
0
        public int ProccessTransport(SipMessageReader reader, out T transaction)
        {
            var key = new BadServerTransactionKey(reader, (reader.IsAck || reader.IsCancel) ? Methods.Invitem : reader.Method);

            lock (sync)
            {
                if (TryGet(key, out transaction) == false)
                {
                    int transactionId = Transaction.InvalidKId;

                    if (reader.Method == Methods.Cancelm)
                    {
                        transactionId = Transaction.ChangeKind(
                            inviteStorage.GetRelaytedTransactionId(key), Transaction.Kind.CancelServer);
                    }

                    if (transactionId == Transaction.InvalidKId)
                    {
                        transactionId = GenerateKId();
                    }

                    transaction = Add(key, GetAcceptedRequestIndex(reader), transactionId);
                }

                int action = transaction.ProccessTransport(reader.Method == Methods.Ackm);

                UpdateOrRemove(transaction);

                return(action);
            }
        }
        public int ProccessTransport(SipMessageReader reader, out T transaction)
        {
            int action = 0;
            int transactionKId;

            if (TryDecodeTransactionKId(reader.Via[0].Branch, out transactionKId))
            {
                if (reader.CSeq.Method == Methods.Cancelm)
                {
                    transactionKId = Transaction.ChangeKind(transactionKId, Transaction.Kind.CancelClient);
                }

                lock (sync)
                {
                    if (TryGet(transactionKId, out transaction))
                    {
                        action = transaction.ProccessTransport(reader.StatusCode.Value);
                        UpdateOrRemove(transaction);
                    }
                    else
                    {
                        action |= Transaction.Action.TransactionNotFound;
                    }
                }
            }
            else
            {
                transaction = new T();

                if (reader.Via[0].Branch.Equals(SipMessageWriter.C.z9hG4bK_NO_TRANSACTION) == false)
                {
                    action |= Transaction.Action.TransactionNotFound;
                }
            }

            return(action);
        }