Search in sources :

Example 1 with RetryAfter

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

the class DialogFilter method sendRequestPendingResponse.

/**
     * Send back a Request Pending response.
     * 
     * @param sipRequest
     * @param transaction
     */
private void sendRequestPendingResponse(SIPRequest sipRequest, SIPServerTransaction transaction) {
    SIPResponse sipResponse = sipRequest.createResponse(Response.REQUEST_PENDING);
    ServerHeader serverHeader = MessageFactoryImpl.getDefaultServerHeader();
    if (serverHeader != null) {
        sipResponse.setHeader(serverHeader);
    }
    try {
        RetryAfter retryAfter = new RetryAfter();
        retryAfter.setRetryAfter(1);
        sipResponse.setHeader(retryAfter);
        if (sipRequest.getMethod().equals(Request.INVITE)) {
            sipStack.addTransactionPendingAck(transaction);
        }
        transaction.sendResponse(sipResponse);
        transaction.releaseSem();
    } catch (Exception ex) {
        sipStack.getStackLogger().logError("Problem sending error response", ex);
        transaction.releaseSem();
        sipStack.removeTransaction(transaction);
    }
}
Also used : SIPResponse(gov.nist.javax.sip.message.SIPResponse) RetryAfter(gov.nist.javax.sip.header.RetryAfter) ServerHeader(javax.sip.header.ServerHeader) InvalidArgumentException(javax.sip.InvalidArgumentException) SipException(javax.sip.SipException) IOException(java.io.IOException) ObjectInUseException(javax.sip.ObjectInUseException)

Example 2 with RetryAfter

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

the class DialogFilter method sendServerInternalErrorResponse.

/**
     * Send back an error Response.
     * 
     * @param sipRequest
     * @param transaction
     */
private void sendServerInternalErrorResponse(SIPRequest sipRequest, SIPServerTransaction transaction) {
    if (sipStack.isLoggingEnabled())
        sipStack.getStackLogger().logDebug("Sending 500 response for out of sequence message");
    SIPResponse sipResponse = sipRequest.createResponse(Response.SERVER_INTERNAL_ERROR);
    sipResponse.setReasonPhrase("Request out of order");
    if (MessageFactoryImpl.getDefaultServerHeader() != null) {
        ServerHeader serverHeader = MessageFactoryImpl.getDefaultServerHeader();
        sipResponse.setHeader(serverHeader);
    }
    try {
        RetryAfter retryAfter = new RetryAfter();
        retryAfter.setRetryAfter(10);
        sipResponse.setHeader(retryAfter);
        sipStack.addTransactionPendingAck(transaction);
        transaction.sendResponse(sipResponse);
        transaction.releaseSem();
    } catch (Exception ex) {
        sipStack.getStackLogger().logError("Problem sending response", ex);
        transaction.releaseSem();
        sipStack.removeTransaction(transaction);
    }
}
Also used : SIPResponse(gov.nist.javax.sip.message.SIPResponse) RetryAfter(gov.nist.javax.sip.header.RetryAfter) ServerHeader(javax.sip.header.ServerHeader) InvalidArgumentException(javax.sip.InvalidArgumentException) SipException(javax.sip.SipException) IOException(java.io.IOException) ObjectInUseException(javax.sip.ObjectInUseException)

Aggregations

RetryAfter (gov.nist.javax.sip.header.RetryAfter)2 SIPResponse (gov.nist.javax.sip.message.SIPResponse)2 IOException (java.io.IOException)2 InvalidArgumentException (javax.sip.InvalidArgumentException)2 ObjectInUseException (javax.sip.ObjectInUseException)2 SipException (javax.sip.SipException)2 ServerHeader (javax.sip.header.ServerHeader)2