Search in sources :

Example 1 with SipProviderImpl

use of gov.nist.javax.sip.SipProviderImpl in project XobotOS by xamarin.

the class SIPServerTransaction method fireRetransmissionTimer.

/**
     * Called by the transaction stack when a retransmission timer fires. This retransmits the
     * last response when the retransmission filter is enabled.
     */
protected void fireRetransmissionTimer() {
    try {
        if (sipStack.isLoggingEnabled()) {
            sipStack.getStackLogger().logDebug("fireRetransmissionTimer() -- ");
        }
        // Resend the last response sent by this transaction
        if (isInviteTransaction() && lastResponse != null) {
            // null can happen if this is terminating when the timer fires.
            if (!this.retransmissionAlertEnabled || sipStack.isTransactionPendingAck(this)) {
                // Retransmit last response until ack.
                if (lastResponse.getStatusCode() / 100 > 2 && !this.isAckSeen)
                    super.sendMessage(lastResponse);
            } else {
                // alert the application to retransmit the last response
                SipProviderImpl sipProvider = (SipProviderImpl) this.getSipProvider();
                TimeoutEvent txTimeout = new TimeoutEvent(sipProvider, this, Timeout.RETRANSMIT);
                sipProvider.handleEvent(txTimeout, this);
            }
        }
    } catch (IOException e) {
        if (sipStack.isLoggingEnabled())
            sipStack.getStackLogger().logException(e);
        raiseErrorEvent(SIPTransactionErrorEvent.TRANSPORT_ERROR);
    }
}
Also used : SipProviderImpl(gov.nist.javax.sip.SipProviderImpl) TimeoutEvent(javax.sip.TimeoutEvent) IOException(java.io.IOException)

Example 2 with SipProviderImpl

use of gov.nist.javax.sip.SipProviderImpl in project XobotOS by xamarin.

the class SIPTransactionStack method removeTransaction.

/**
     * Remove transaction. This actually gets the tx out of the search structures which the stack
     * keeps around. When the tx
     */
public void removeTransaction(SIPTransaction sipTransaction) {
    if (stackLogger.isLoggingEnabled()) {
        stackLogger.logDebug("Removing Transaction = " + sipTransaction.getTransactionId() + " transaction = " + sipTransaction);
    }
    if (sipTransaction instanceof SIPServerTransaction) {
        if (stackLogger.isLoggingEnabled())
            stackLogger.logStackTrace();
        String key = sipTransaction.getTransactionId();
        Object removed = serverTransactionTable.remove(key);
        String method = sipTransaction.getMethod();
        this.removePendingTransaction((SIPServerTransaction) sipTransaction);
        this.removeTransactionPendingAck((SIPServerTransaction) sipTransaction);
        if (method.equalsIgnoreCase(Request.INVITE)) {
            this.removeFromMergeTable((SIPServerTransaction) sipTransaction);
        }
        // Send a notification to the listener.
        SipProviderImpl sipProvider = (SipProviderImpl) sipTransaction.getSipProvider();
        if (removed != null && sipTransaction.testAndSetTransactionTerminatedEvent()) {
            TransactionTerminatedEvent event = new TransactionTerminatedEvent(sipProvider, (ServerTransaction) sipTransaction);
            sipProvider.handleEvent(event, sipTransaction);
        }
    } else {
        String key = sipTransaction.getTransactionId();
        Object removed = clientTransactionTable.remove(key);
        if (stackLogger.isLoggingEnabled()) {
            stackLogger.logDebug("REMOVED client tx " + removed + " KEY = " + key);
            if (removed != null) {
                SIPClientTransaction clientTx = (SIPClientTransaction) removed;
                if (clientTx.getMethod().equals(Request.INVITE) && this.maxForkTime != 0) {
                    RemoveForkedTransactionTimerTask ttask = new RemoveForkedTransactionTimerTask(clientTx);
                    this.timer.schedule(ttask, this.maxForkTime * 1000);
                }
            }
        }
        // Send a notification to the listener.
        if (removed != null && sipTransaction.testAndSetTransactionTerminatedEvent()) {
            SipProviderImpl sipProvider = (SipProviderImpl) sipTransaction.getSipProvider();
            TransactionTerminatedEvent event = new TransactionTerminatedEvent(sipProvider, (ClientTransaction) sipTransaction);
            sipProvider.handleEvent(event, sipTransaction);
        }
    }
}
Also used : SipProviderImpl(gov.nist.javax.sip.SipProviderImpl) TransactionTerminatedEvent(javax.sip.TransactionTerminatedEvent)

Aggregations

SipProviderImpl (gov.nist.javax.sip.SipProviderImpl)2 IOException (java.io.IOException)1 TimeoutEvent (javax.sip.TimeoutEvent)1 TransactionTerminatedEvent (javax.sip.TransactionTerminatedEvent)1