Search in sources :

Example 1 with TimeoutEvent

use of javax.sip.TimeoutEvent in project XobotOS by xamarin.

the class SIPClientTransaction method fireRetransmissionTimer.

/**
     * Called by the transaction stack when a retransmission timer fires.
     */
protected void fireRetransmissionTimer() {
    try {
        // Resend the last request sent
        if (this.getState() == null || !this.isMapped)
            return;
        boolean inv = isInviteTransaction();
        TransactionState s = this.getState();
        // Bug-fix for non-INVITE transactions not retransmitted when 1xx response received
        if ((inv && TransactionState.CALLING == s) || (!inv && (TransactionState.TRYING == s || TransactionState.PROCEEDING == s))) {
            if (lastRequest != null) {
                if (sipStack.generateTimeStampHeader && lastRequest.getHeader(TimeStampHeader.NAME) != null) {
                    long milisec = System.currentTimeMillis();
                    TimeStamp timeStamp = new TimeStamp();
                    try {
                        timeStamp.setTimeStamp(milisec);
                    } catch (InvalidArgumentException ex) {
                        InternalErrorHandler.handleException(ex);
                    }
                    lastRequest.setHeader(timeStamp);
                }
                super.sendMessage(lastRequest);
                if (this.notifyOnRetransmit) {
                    TimeoutEvent txTimeout = new TimeoutEvent(this.getSipProvider(), this, Timeout.RETRANSMIT);
                    this.getSipProvider().handleEvent(txTimeout, this);
                }
                if (this.timeoutIfStillInCallingState && this.getState() == TransactionState.CALLING) {
                    this.callingStateTimeoutCount--;
                    if (callingStateTimeoutCount == 0) {
                        TimeoutEvent timeoutEvent = new TimeoutEvent(this.getSipProvider(), this, Timeout.RETRANSMIT);
                        this.getSipProvider().handleEvent(timeoutEvent, this);
                        this.timeoutIfStillInCallingState = false;
                    }
                }
            }
        }
    } catch (IOException e) {
        this.raiseIOExceptionEvent();
        raiseErrorEvent(SIPTransactionErrorEvent.TRANSPORT_ERROR);
    }
}
Also used : TransactionState(javax.sip.TransactionState) InvalidArgumentException(javax.sip.InvalidArgumentException) TimeoutEvent(javax.sip.TimeoutEvent) IOException(java.io.IOException) TimeStamp(gov.nist.javax.sip.header.TimeStamp)

Example 2 with TimeoutEvent

use of javax.sip.TimeoutEvent 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 3 with TimeoutEvent

use of javax.sip.TimeoutEvent in project XobotOS by xamarin.

the class SipProviderImpl method transactionErrorEvent.

/**
     * Invoked when an error has ocurred with a transaction. Propagate up to the
     * listeners.
     *
     * @param transactionErrorEvent
     *            Error event.
     */
public void transactionErrorEvent(SIPTransactionErrorEvent transactionErrorEvent) {
    SIPTransaction transaction = (SIPTransaction) transactionErrorEvent.getSource();
    if (transactionErrorEvent.getErrorID() == SIPTransactionErrorEvent.TRANSPORT_ERROR) {
        // There must be a way to inform the TU here!!
        if (sipStack.isLoggingEnabled()) {
            sipStack.getStackLogger().logDebug("TransportError occured on " + transaction);
        }
        // Treat this like a timeout event. (Suggestion from Christophe).
        Object errorObject = transactionErrorEvent.getSource();
        Timeout timeout = Timeout.TRANSACTION;
        TimeoutEvent ev = null;
        if (errorObject instanceof SIPServerTransaction) {
            ev = new TimeoutEvent(this, (ServerTransaction) errorObject, timeout);
        } else {
            SIPClientTransaction clientTx = (SIPClientTransaction) errorObject;
            Hop hop = clientTx.getNextHop();
            if (sipStack.getRouter() instanceof RouterExt) {
                ((RouterExt) sipStack.getRouter()).transactionTimeout(hop);
            }
            ev = new TimeoutEvent(this, (ClientTransaction) errorObject, timeout);
        }
        // Handling transport error like timeout
        this.handleEvent(ev, (SIPTransaction) errorObject);
    } else if (transactionErrorEvent.getErrorID() == SIPTransactionErrorEvent.TIMEOUT_ERROR) {
        // This is a timeout event.
        Object errorObject = transactionErrorEvent.getSource();
        Timeout timeout = Timeout.TRANSACTION;
        TimeoutEvent ev = null;
        if (errorObject instanceof SIPServerTransaction) {
            ev = new TimeoutEvent(this, (ServerTransaction) errorObject, timeout);
        } else {
            SIPClientTransaction clientTx = (SIPClientTransaction) errorObject;
            Hop hop = clientTx.getNextHop();
            if (sipStack.getRouter() instanceof RouterExt) {
                ((RouterExt) sipStack.getRouter()).transactionTimeout(hop);
            }
            ev = new TimeoutEvent(this, (ClientTransaction) errorObject, timeout);
        }
        this.handleEvent(ev, (SIPTransaction) errorObject);
    } else if (transactionErrorEvent.getErrorID() == SIPTransactionErrorEvent.TIMEOUT_RETRANSMIT) {
        // This is a timeout retransmit event.
        // We should never get this if retransmit filter is
        // enabled (ie. in that case the stack should handle.
        // all retransmits.
        Object errorObject = transactionErrorEvent.getSource();
        Transaction tx = (Transaction) errorObject;
        if (tx.getDialog() != null)
            InternalErrorHandler.handleException("Unexpected event !", this.sipStack.getStackLogger());
        Timeout timeout = Timeout.RETRANSMIT;
        TimeoutEvent ev = null;
        if (errorObject instanceof SIPServerTransaction) {
            ev = new TimeoutEvent(this, (ServerTransaction) errorObject, timeout);
        } else {
            ev = new TimeoutEvent(this, (ClientTransaction) errorObject, timeout);
        }
        this.handleEvent(ev, (SIPTransaction) errorObject);
    }
}
Also used : SIPClientTransaction(gov.nist.javax.sip.stack.SIPClientTransaction) TimeoutEvent(javax.sip.TimeoutEvent) ServerTransaction(javax.sip.ServerTransaction) Transaction(javax.sip.Transaction) SIPServerTransaction(gov.nist.javax.sip.stack.SIPServerTransaction) SIPClientTransaction(gov.nist.javax.sip.stack.SIPClientTransaction) SIPTransaction(gov.nist.javax.sip.stack.SIPTransaction) ClientTransaction(javax.sip.ClientTransaction) RouterExt(gov.nist.javax.sip.address.RouterExt) Timeout(javax.sip.Timeout) SIPTransaction(gov.nist.javax.sip.stack.SIPTransaction) SIPClientTransaction(gov.nist.javax.sip.stack.SIPClientTransaction) ClientTransaction(javax.sip.ClientTransaction) Hop(javax.sip.address.Hop) EventObject(java.util.EventObject) ServerTransaction(javax.sip.ServerTransaction) SIPServerTransaction(gov.nist.javax.sip.stack.SIPServerTransaction) SIPServerTransaction(gov.nist.javax.sip.stack.SIPServerTransaction)

Aggregations

TimeoutEvent (javax.sip.TimeoutEvent)3 IOException (java.io.IOException)2 SipProviderImpl (gov.nist.javax.sip.SipProviderImpl)1 RouterExt (gov.nist.javax.sip.address.RouterExt)1 TimeStamp (gov.nist.javax.sip.header.TimeStamp)1 SIPClientTransaction (gov.nist.javax.sip.stack.SIPClientTransaction)1 SIPServerTransaction (gov.nist.javax.sip.stack.SIPServerTransaction)1 SIPTransaction (gov.nist.javax.sip.stack.SIPTransaction)1 EventObject (java.util.EventObject)1 ClientTransaction (javax.sip.ClientTransaction)1 InvalidArgumentException (javax.sip.InvalidArgumentException)1 ServerTransaction (javax.sip.ServerTransaction)1 Timeout (javax.sip.Timeout)1 Transaction (javax.sip.Transaction)1 TransactionState (javax.sip.TransactionState)1 Hop (javax.sip.address.Hop)1