本文整理汇总了Java中gov.nist.javax.sip.message.SIPResponse.setReasonPhrase方法的典型用法代码示例。如果您正苦于以下问题:Java SIPResponse.setReasonPhrase方法的具体用法?Java SIPResponse.setReasonPhrase怎么用?Java SIPResponse.setReasonPhrase使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gov.nist.javax.sip.message.SIPResponse
的用法示例。
在下文中一共展示了SIPResponse.setReasonPhrase方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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);
}
}
}
示例2: 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);
}
}
}