use of javax.sip.message.Response in project XobotOS by xamarin.
the class SipHelper method sendInviteOk.
/**
* @param event the INVITE request event
*/
public ServerTransaction sendInviteOk(RequestEvent event, SipProfile localProfile, String sessionDescription, ServerTransaction inviteTransaction, String externalIp, int externalPort) throws SipException {
try {
Request request = event.getRequest();
Response response = mMessageFactory.createResponse(Response.OK, request);
response.addHeader(createContactHeader(localProfile, externalIp, externalPort));
response.setContent(sessionDescription, mHeaderFactory.createContentTypeHeader("application", "sdp"));
if (inviteTransaction == null) {
inviteTransaction = getServerTransaction(event);
}
if (inviteTransaction.getState() != TransactionState.COMPLETED) {
if (DEBUG)
Log.d(TAG, "send OK: " + response);
inviteTransaction.sendResponse(response);
}
return inviteTransaction;
} catch (ParseException e) {
throw new SipException("sendInviteOk()", e);
}
}
use of javax.sip.message.Response in project XobotOS by xamarin.
the class SipHelper method sendInviteAck.
/**
* @param event the INVITE ACK request event
*/
public void sendInviteAck(ResponseEvent event, Dialog dialog) throws SipException {
Response response = event.getResponse();
long cseq = ((CSeqHeader) response.getHeader(CSeqHeader.NAME)).getSeqNumber();
Request ack = dialog.createAck(cseq);
if (DEBUG)
Log.d(TAG, "send ACK: " + ack);
dialog.sendAck(ack);
}
use of javax.sip.message.Response in project XobotOS by xamarin.
the class SipSessionGroup method expectResponse.
/**
* @return true if the event is a response event and the CSeqHeader method
* match the given arguments; false otherwise
*/
private static boolean expectResponse(String expectedMethod, EventObject evt) {
if (evt instanceof ResponseEvent) {
ResponseEvent event = (ResponseEvent) evt;
Response response = event.getResponse();
return expectedMethod.equalsIgnoreCase(getCseqMethod(response));
}
return false;
}
use of javax.sip.message.Response in project XobotOS by xamarin.
the class SipSessionGroup method expectResponse.
/**
* @return true if the event is a response event and the response code and
* CSeqHeader method match the given arguments; false otherwise
*/
private static boolean expectResponse(int responseCode, String expectedMethod, EventObject evt) {
if (evt instanceof ResponseEvent) {
ResponseEvent event = (ResponseEvent) evt;
Response response = event.getResponse();
if (response.getStatusCode() == responseCode) {
return expectedMethod.equalsIgnoreCase(getCseqMethod(response));
}
}
return false;
}
use of javax.sip.message.Response in project XobotOS by xamarin.
the class DialogFilter method processResponse.
/**
* Process the response.
*
* @exception SIPServerException is thrown when there is an error processing the response
* @param incomingMessageChannel -- message channel on which the response is received.
*/
public void processResponse(SIPResponse response, MessageChannel incomingMessageChannel, SIPDialog dialog) {
if (sipStack.isLoggingEnabled()) {
sipStack.getStackLogger().logDebug("PROCESSING INCOMING RESPONSE" + response.encodeMessage());
}
if (listeningPoint == null) {
if (sipStack.isLoggingEnabled())
sipStack.getStackLogger().logError("Dropping message: No listening point" + " registered!");
return;
}
if (sipStack.checkBranchId() && !Utils.getInstance().responseBelongsToUs(response)) {
if (sipStack.isLoggingEnabled()) {
sipStack.getStackLogger().logError("Dropping response - topmost VIA header does not originate from this stack");
}
return;
}
SipProviderImpl sipProvider = listeningPoint.getProvider();
if (sipProvider == null) {
if (sipStack.isLoggingEnabled()) {
sipStack.getStackLogger().logError("Dropping message: no provider");
}
return;
}
if (sipProvider.getSipListener() == null) {
if (sipStack.isLoggingEnabled()) {
sipStack.getStackLogger().logError("No listener -- dropping response!");
}
return;
}
SIPClientTransaction transaction = (SIPClientTransaction) this.transactionChannel;
SipStackImpl sipStackImpl = sipProvider.sipStack;
if (sipStack.isLoggingEnabled()) {
sipStackImpl.getStackLogger().logDebug("Transaction = " + transaction);
}
if (transaction == null) {
// we cannot drop the response.
if (dialog != null) {
if (response.getStatusCode() / 100 != 2) {
if (sipStack.isLoggingEnabled()) {
sipStack.getStackLogger().logDebug("Response is not a final response and dialog is found for response -- dropping response!");
}
return;
} else if (dialog.getState() == DialogState.TERMINATED) {
if (sipStack.isLoggingEnabled()) {
sipStack.getStackLogger().logDebug("Dialog is terminated -- dropping response!");
}
return;
} else {
boolean ackAlreadySent = false;
if (dialog.isAckSeen() && dialog.getLastAckSent() != null) {
if (dialog.getLastAckSent().getCSeq().getSeqNumber() == response.getCSeq().getSeqNumber()) {
// the last ack sent corresponded to this 200
ackAlreadySent = true;
}
}
// 200 retransmission for the final response.
if (ackAlreadySent && response.getCSeq().getMethod().equals(dialog.getMethod())) {
try {
// dont pass up the null transaction
if (sipStack.isLoggingEnabled()) {
sipStack.getStackLogger().logDebug("Retransmission of OK detected: Resending last ACK");
}
dialog.resendAck();
return;
} catch (SipException ex) {
// What to do here ?? kill the dialog?
sipStack.getStackLogger().logError("could not resend ack", ex);
}
}
}
}
if (sipStack.isLoggingEnabled()) {
sipStack.getStackLogger().logDebug("could not find tx, handling statelessly Dialog = " + dialog);
}
// Pass the response up to the application layer to handle
// statelessly.
ResponseEventExt sipEvent = new ResponseEventExt(sipProvider, transaction, dialog, (Response) response);
if (response.getCSeqHeader().getMethod().equals(Request.INVITE)) {
SIPClientTransaction forked = this.sipStack.getForkedTransaction(response.getTransactionId());
sipEvent.setOriginalTransaction(forked);
}
sipProvider.handleEvent(sipEvent, transaction);
return;
}
ResponseEventExt responseEvent = null;
// Here if there is an assigned dialog
responseEvent = new ResponseEventExt(sipProvider, (ClientTransactionExt) transaction, dialog, (Response) response);
if (response.getCSeqHeader().getMethod().equals(Request.INVITE)) {
SIPClientTransaction forked = this.sipStack.getForkedTransaction(response.getTransactionId());
responseEvent.setOriginalTransaction(forked);
}
// Set the Dialog for the response.
if (dialog != null && response.getStatusCode() != 100) {
// set the last response for the dialog.
dialog.setLastResponse(transaction, response);
transaction.setDialog(dialog, dialog.getDialogId());
}
sipProvider.handleEvent(responseEvent, transaction);
}
Aggregations