本文整理汇总了Java中gov.nist.javax.sip.message.SIPResponse类的典型用法代码示例。如果您正苦于以下问题:Java SIPResponse类的具体用法?Java SIPResponse怎么用?Java SIPResponse使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
SIPResponse类属于gov.nist.javax.sip.message包,在下文中一共展示了SIPResponse类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: SIPDialog
import gov.nist.javax.sip.message.SIPResponse; //导入依赖的package包/类
/**
* create a sip dialog with a response ( no tx)
*/
public SIPDialog(SipProviderImpl sipProvider, SIPResponse sipResponse) {
this(sipProvider);
this.sipStack = (SIPTransactionStack) sipProvider.getSipStack();
this.setLastResponse(null, sipResponse);
this.localSequenceNumber = sipResponse.getCSeq().getSeqNumber();
this.originalLocalSequenceNumber = localSequenceNumber;
this.localParty = sipResponse.getFrom().getAddress();
this.remoteParty = sipResponse.getTo().getAddress();
this.method = sipResponse.getCSeq().getMethod();
this.callIdHeader = sipResponse.getCallId();
this.serverTransactionFlag = false;
this.setLocalTag(sipResponse.getFrom().getTag());
this.setRemoteTag(sipResponse.getTo().getTag());
if (logger.isLoggingEnabled(LogWriter.TRACE_DEBUG)) {
logger.logDebug("Creating a dialog : " + this);
logger.logStackTrace();
}
this.isBackToBackUserAgent = sipStack.isBackToBackUserAgent;
addEventListener(sipStack);
releaseReferences = sipStack.isAggressiveCleanup();
}
示例4: setResponseTags
import gov.nist.javax.sip.message.SIPResponse; //导入依赖的package包/类
/**
* Check the tags of the response against the tags of the Dialog. Return
* true if the respnse matches the tags of the dialog. We do this check wehn
* sending out a response.
*
* @param sipResponse
* -- the response to check.
*
*/
public void setResponseTags(SIPResponse sipResponse) {
if (this.getLocalTag() != null || this.getRemoteTag() != null) {
return;
}
String responseFromTag = sipResponse.getFromTag();
if (responseFromTag != null) {
if (responseFromTag.equals(this.getLocalTag())) {
sipResponse.setToTag(this.getRemoteTag());
} else if (responseFromTag.equals(this.getRemoteTag())) {
sipResponse.setToTag(this.getLocalTag());
}
} else {
if (logger.isLoggingEnabled())
logger.logWarning(
"No from tag in response! Not RFC 3261 compatible.");
}
}
示例5: checkFromTag
import gov.nist.javax.sip.message.SIPResponse; //导入依赖的package包/类
/**
* @see SIPClientTransaction#checkFromTag(gov.nist.javax.sip.message.SIPResponse)
*/
@Override
public boolean checkFromTag(SIPResponse sipResponse) {
String originalFromTag = getOriginalRequestFromTag();
if (this.defaultDialog != null) {
if (originalFromTag == null ^ sipResponse.getFrom().getTag() == null) {
if (logger.isLoggingEnabled(LogWriter.TRACE_DEBUG))
logger.logDebug("From tag mismatch -- dropping response");
return false;
}
if (originalFromTag != null
&& !originalFromTag.equalsIgnoreCase(sipResponse.getFrom().getTag()))
{
if (logger.isLoggingEnabled(LogWriter.TRACE_DEBUG))
logger.logDebug("From tag mismatch -- dropping response");
return false;
}
}
return true;
}
示例6: testResponse
import gov.nist.javax.sip.message.SIPResponse; //导入依赖的package包/类
@Test
public void testResponse() throws Exception
{
SIPResponse response = new SIPResponse();
response.setStatusCode(180);
assertTrue(sot.create(response) instanceof ProvisionalMessage);
response.setStatusCode(199);
assertTrue(sot.create(response) instanceof ProvisionalMessage);
response.setStatusCode(200);
assertTrue(sot.create(response) instanceof SuccessMessage);
response.setStatusCode(299);
assertTrue(sot.create(response) instanceof SuccessMessage);
response.setStatusCode(300);
assertTrue(sot.create(response) instanceof ErrorMessage);
response.setStatusCode(404);
assertTrue(sot.create(response) instanceof ErrorMessage);
}
示例7: 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);
}
}
}
示例8: 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);
}
}
}
示例9: 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);
}
}
}
示例10: 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);
}
}
}
示例11: createPrack
import gov.nist.javax.sip.message.SIPResponse; //导入依赖的package包/类
public Request createPrack(Response relResponse)
throws DialogDoesNotExistException, SipException {
if (this.getState() == null
|| this.getState().equals(DialogState.TERMINATED))
throw new DialogDoesNotExistException(
"Dialog not initialized or terminated");
if ((RSeq) relResponse.getHeader(RSeqHeader.NAME) == null) {
throw new SipException("Missing RSeq Header");
}
try {
SIPResponse sipResponse = (SIPResponse) relResponse;
SIPRequest sipRequest = this.createRequest(Request.PRACK,
sipResponse.getTopmostVia().getTransport());
String toHeaderTag = sipResponse.getTo().getTag();
sipRequest.setToTag(toHeaderTag);
RAck rack = new RAck();
RSeq rseq = (RSeq) relResponse.getHeader(RSeqHeader.NAME);
rack.setMethod(sipResponse.getCSeq().getMethod());
rack.setCSequenceNumber((int) sipResponse.getCSeq().getSeqNumber());
rack.setRSequenceNumber(rseq.getSeqNumber());
sipRequest.setHeader(rack);
if (this.proxyAuthorizationHeader != null) {
sipRequest.addHeader(proxyAuthorizationHeader);
}
return (Request) sipRequest;
} catch (Exception ex) {
InternalErrorHandler.handleException(ex);
return null;
}
}
示例12: checkRetransmissionForForking
import gov.nist.javax.sip.message.SIPResponse; //导入依赖的package包/类
public void checkRetransmissionForForking(SIPResponse response) {
final int statusCode = response.getStatusCode();
final String responseMethod = response.getCSeqHeader().getMethod();
final long responseCSeqNumber = response.getCSeq().getSeqNumber();
boolean isRetransmission = !responsesReceivedInForkingCase.add(statusCode + "/" + responseCSeqNumber + "/" + responseMethod);
response.setRetransmission(isRetransmission);
if (logger.isLoggingEnabled(LogWriter.TRACE_DEBUG)) {
logger.logDebug(
"marking response as retransmission " + isRetransmission + " for dialog " + this);
}
}
示例13: logResponse
import gov.nist.javax.sip.message.SIPResponse; //导入依赖的package包/类
/**
* Log a response received at this message channel. This is used for processing incoming
* responses to a client transaction.
*
* @param receptionTime is the time at which the response was received.
* @param status is the processing status of the message.
*
*/
public void logResponse(SIPResponse sipResponse, long receptionTime, String status) {
int peerport = getPeerPort();
if (peerport == 0 && sipResponse.getContactHeaders() != null) {
ContactHeader contact = (ContactHeader) sipResponse.getContactHeaders().getFirst();
peerport = ((AddressImpl) contact.getAddress()).getPort();
}
String from = getPeerAddress().toString() + ":" + peerport;
String to = this.getHost() + ":" + getPort();
this.getSIPStack().serverLogger.logMessage(sipResponse, from, to, status, false,
receptionTime);
}
示例14: createDialog
import gov.nist.javax.sip.message.SIPResponse; //导入依赖的package包/类
/**
* Create a Dialog given a client tx and response.
*
* @param transaction
* @param sipResponse
* @return
*/
public SIPDialog createDialog(SIPClientTransaction transaction,
SIPResponse sipResponse) {
String originalDialogId = ((SIPRequest)transaction.getRequest()).getDialogId(false);
String earlyDialogId = sipResponse.getDialogId(false);
if (logger.isLoggingEnabled(LogLevels.TRACE_DEBUG)) {
logger.logDebug("createDialog originalDialogId=" + originalDialogId);
logger.logDebug("createDialog earlyDialogId=" + earlyDialogId);
logger.logDebug("createDialog default Dialog=" + transaction.getDefaultDialog());
if(transaction.getDefaultDialog() != null) {
logger.logDebug("createDialog default Dialog Id=" + transaction.getDefaultDialog().getDialogId());
}
}
SIPDialog retval = null;
SIPDialog earlyDialog = this.earlyDialogTable.get(originalDialogId);
if (earlyDialog != null && transaction != null && (transaction.getDefaultDialog() == null || transaction.getDefaultDialog().getDialogId().equals(originalDialogId))) {
retval = earlyDialog;
if (logger.isLoggingEnabled(LogLevels.TRACE_DEBUG)) {
logger.logDebug("createDialog early Dialog found : earlyDialogId="
+ originalDialogId + " earlyDialog= " + retval);
}
if (sipResponse.isFinalResponse()) {
this.earlyDialogTable.remove(originalDialogId);
}
} else {
retval = new SIPDialog(transaction, sipResponse);
if (logger.isLoggingEnabled(LogLevels.TRACE_DEBUG)) {
logger.logDebug("createDialog early Dialog not found : earlyDialogId="
+ earlyDialogId + " created one " + retval);
}
}
return retval;
}
示例15: processRequest
import gov.nist.javax.sip.message.SIPResponse; //导入依赖的package包/类
public boolean processRequest(SIPRequest request,
MessageChannel messageChannel) {
String requestMethod = request.getMethod();
// We should not attempt to drop these requests because they actually free resources
// which is our goal in congested mode
boolean undropableMethod = requestMethod.equals(Request.BYE)
|| requestMethod.equals(Request.ACK)
|| requestMethod.equals(Request.PRACK)
|| requestMethod.equals(Request.CANCEL);
if(!undropableMethod) {
if(serverTransactionTableHighwaterMark <= sipStack.getServerTransactionTableSize()) {
// Allow directly any subsequent requests
if(request.getToTag() != null) {
return true;
}
if(dropResponseStatus>0) {
SIPResponse response = request.createResponse(dropResponseStatus);
try {
messageChannel.sendMessage(response);
} catch (IOException e) {
logger.logError("Failed to send congestion control error response" + response, e);
}
}
return false; // Do not pass this request to the pipeline
}
}
return true; // OK, the processing of the request can continue
}