當前位置: 首頁>>代碼示例>>Java>>正文


Java SIPResponse.setHeader方法代碼示例

本文整理匯總了Java中gov.nist.javax.sip.message.SIPResponse.setHeader方法的典型用法代碼示例。如果您正苦於以下問題:Java SIPResponse.setHeader方法的具體用法?Java SIPResponse.setHeader怎麽用?Java SIPResponse.setHeader使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在gov.nist.javax.sip.message.SIPResponse的用法示例。


在下文中一共展示了SIPResponse.setHeader方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: sendLoopDetectedResponse

import gov.nist.javax.sip.message.SIPResponse; //導入方法依賴的package包/類
/**
 * Send back a LOOP Detected Response.
 * 
 * @param sipRequest
 * @param transaction
 * 
 */
private void sendLoopDetectedResponse(SIPRequest sipRequest,
        SIPServerTransaction transaction) {
    SIPResponse sipResponse = sipRequest
            .createResponse(Response.LOOP_DETECTED);
    if (transaction.getState() != TransactionState.TERMINATED) {

        ServerHeader serverHeader = MessageFactoryImpl
                .getDefaultServerHeader();
        if (serverHeader != null) {
            sipResponse.setHeader(serverHeader);
        }
        try {
            sipStack.addTransactionPendingAck(transaction);
            transaction.sendResponse(sipResponse);
            transaction.releaseSem();
        } catch (Exception ex) {
            logger.logError(
                    "Problem sending error response", ex);
            transaction.releaseSem();
            sipStack.removeTransaction(transaction);

        }
    }

}
 
開發者ID:YunlongYang,項目名稱:LightSIP,代碼行數:33,代碼來源:DialogFilter.java

示例2: sendTryingResponse

import gov.nist.javax.sip.message.SIPResponse; //導入方法依賴的package包/類
/**
 * Send back a Trying Response.
 * 
 * @param sipRequest
 * @param transaction
 * 
 */
private void sendTryingResponse(SIPRequest sipRequest,
        SIPServerTransaction transaction) {
    SIPResponse sipResponse = sipRequest
            .createResponse(Response.TRYING);
    if (transaction.getState() != TransactionState.TERMINATED) {

        ServerHeader serverHeader = MessageFactoryImpl
                .getDefaultServerHeader();
        if (serverHeader != null) {
            sipResponse.setHeader(serverHeader);
        }
        try {
            transaction.sendResponse(sipResponse);
            transaction.releaseSem();
        } catch (Exception ex) {
            logger.logError(
                    "Problem sending error response", ex);
            transaction.releaseSem();
            sipStack.removeTransaction(transaction);

        }
    }

}
 
開發者ID:YunlongYang,項目名稱:LightSIP,代碼行數:32,代碼來源:DialogFilter.java

示例3: sendRequestPendingResponse

import gov.nist.javax.sip.message.SIPResponse; //導入方法依賴的package包/類
/**
 * Send back a Request Pending response.
 * 
 * @param sipRequest
 * @param transaction
 */
private void sendRequestPendingResponse(SIPRequest sipRequest,
        SIPServerTransaction transaction) {
    if (transaction.getState() != TransactionState.TERMINATED) {
        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) {
            logger.logError(
                    "Problem sending error response", ex);
            transaction.releaseSem();
            sipStack.removeTransaction(transaction);
        }
    }
}
 
開發者ID:YunlongYang,項目名稱:LightSIP,代碼行數:34,代碼來源:DialogFilter.java

示例4: sendBadRequestResponse

import gov.nist.javax.sip.message.SIPResponse; //導入方法依賴的package包/類
/**
 * Send a BAD REQUEST response.
 * 
 * @param sipRequest
 * @param transaction
 * @param reasonPhrase
 */

private void sendBadRequestResponse(SIPRequest sipRequest,
        SIPServerTransaction transaction, String reasonPhrase) {
    if (transaction.getState() != TransactionState.TERMINATED) {

        SIPResponse sipResponse = sipRequest
                .createResponse(Response.BAD_REQUEST);
        if (reasonPhrase != null)
            sipResponse.setReasonPhrase(reasonPhrase);
        ServerHeader serverHeader = MessageFactoryImpl
                .getDefaultServerHeader();
        if (serverHeader != null) {
            sipResponse.setHeader(serverHeader);
        }
        try {
            if (sipRequest.getMethod().equals(Request.INVITE)) {
                sipStack.addTransactionPendingAck(transaction);
            }
            transaction.sendResponse(sipResponse);
            transaction.releaseSem();
        } catch (Exception ex) {
            logger.logError(
                    "Problem sending error response", ex);
            transaction.releaseSem();
            sipStack.removeTransaction(transaction);

        }
    }
}
 
開發者ID:YunlongYang,項目名稱:LightSIP,代碼行數:37,代碼來源:DialogFilter.java

示例5: sendCallOrTransactionDoesNotExistResponse

import gov.nist.javax.sip.message.SIPResponse; //導入方法依賴的package包/類
/**
 * Send a CALL OR TRANSACTION DOES NOT EXIST response.
 * 
 * @param sipRequest
 * @param transaction
 */

private void sendCallOrTransactionDoesNotExistResponse(
        SIPRequest sipRequest, SIPServerTransaction transaction) {

    if (transaction.getState() != TransactionState.TERMINATED) {
        SIPResponse sipResponse = sipRequest
                .createResponse(Response.CALL_OR_TRANSACTION_DOES_NOT_EXIST);

        ServerHeader serverHeader = MessageFactoryImpl
                .getDefaultServerHeader();
        if (serverHeader != null) {
            sipResponse.setHeader(serverHeader);
        }
        try {
            if (sipRequest.getMethod().equals(Request.INVITE)) {
                sipStack.addTransactionPendingAck(transaction);
            }
            transaction.sendResponse(sipResponse);
            transaction.releaseSem();
        } catch (Exception ex) {
            logger.logError(
                    "Problem sending error response", ex);
            transaction.releaseSem();
            sipStack.removeTransaction(transaction);

        }

    }
}
 
開發者ID:YunlongYang,項目名稱:LightSIP,代碼行數:36,代碼來源:DialogFilter.java

示例6: sendServerInternalErrorResponse

import gov.nist.javax.sip.message.SIPResponse; //導入方法依賴的package包/類
/**
 * Send back an error Response.
 * 
 * @param sipRequest
 * @param transaction
 */

private void sendServerInternalErrorResponse(SIPRequest sipRequest,
        SIPServerTransaction transaction) {
    if (transaction.getState() != TransactionState.TERMINATED) {
        if (logger.isLoggingEnabled(LogWriter.TRACE_DEBUG))
            logger.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) {
            logger.logError("Problem sending response",
                    ex);
            transaction.releaseSem();
            sipStack.removeTransaction(transaction);
        }
    }
}
 
開發者ID:YunlongYang,項目名稱:LightSIP,代碼行數:38,代碼來源:DialogFilter.java

示例7: createReliableProvisionalResponse

import gov.nist.javax.sip.message.SIPResponse; //導入方法依賴的package包/類
public Response createReliableProvisionalResponse(int statusCode)
        throws InvalidArgumentException, SipException {

    if (!(firstTransactionIsServerTransaction)) {
        throw new SipException("Not a Server Dialog!");

    }
    /*
     * A UAS MUST NOT attempt to send a 100 (Trying) response reliably. Only
     * provisional responses numbered 101 to 199 may be sent reliably. If
     * the request did not include either a Supported or Require header
     * field indicating this feature, the UAS MUST NOT send the provisional
     * response reliably.
     */
    if (statusCode <= 100 || statusCode > 199)
        throw new InvalidArgumentException("Bad status code ");
    SIPRequest request = this.originalRequest;
    if (!request.getMethod().equals(Request.INVITE))
        throw new SipException("Bad method");

    ListIterator<SIPHeader> list = request.getHeaders(SupportedHeader.NAME);
    if (list == null || !optionPresent(list, "100rel")) {
        list = request.getHeaders(RequireHeader.NAME);
        if (list == null || !optionPresent(list, "100rel")) {
            throw new SipException(
                    "No Supported/Require 100rel header in the request");
        }
    }

    SIPResponse response = request.createResponse(statusCode);
    /*
     * The provisional response to be sent reliably is constructed by the
     * UAS core according to the procedures of Section 8.2.6 of RFC 3261. In
     * addition, it MUST contain a Require header field containing the
     * option tag 100rel, and MUST include an RSeq header field. The value
     * of the header field for the first reliable provisional response in a
     * transaction MUST be between 1 and 231 - 1. It is RECOMMENDED that it
     * be chosen uniformly in this range. The RSeq numbering space is within
     * a single transaction. This means that provisional responses for
     * different requests MAY use the same values for the RSeq number.
     */
    Require require = new Require();
    try {
        require.setOptionTag("100rel");
    } catch (Exception ex) {
        InternalErrorHandler.handleException(ex);
    }
    response.addHeader(require);
    RSeq rseq = new RSeq();
    /*
     * set an arbitrary sequence number. This is actually set when the
     * response is sent out
     */
    rseq.setSeqNumber(1L);
    /*
     * Copy the record route headers from the request to the response (
     * Issue 160 ). Note that other 1xx headers do not get their Record
     * Route headers copied over but reliable provisional responses do. See
     * RFC 3262 Table 2.
     */
    RecordRouteList rrl = request.getRecordRouteHeaders();
    if (rrl != null) {
        RecordRouteList rrlclone = (RecordRouteList) rrl.clone();
        response.setHeader(rrlclone);
    }

    return response;
}
 
開發者ID:YunlongYang,項目名稱:LightSIP,代碼行數:69,代碼來源:SIPDialog.java


注:本文中的gov.nist.javax.sip.message.SIPResponse.setHeader方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。