本文整理汇总了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);
}
}
}
示例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);
}
}
}
示例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);
}
}
}
示例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);
}
}
}
示例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);
}
}
}
示例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);
}
}
}
示例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;
}