当前位置: 首页>>代码示例>>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;未经允许,请勿转载。