use of gov.nist.javax.sip.RequestEventExt in project jain-sip.ha by RestComm.
the class SimpleStatefulProxy method processBye.
public void processBye(RequestEvent requestEvent) {
try {
serverTransaction = requestEvent.getServerTransaction();
if (serverTransaction == null) {
try {
serverTransaction = sipProvider.getNewServerTransaction(requestEvent.getRequest());
} catch (Exception e) {
((SipStackImpl) sipStack).getStackLogger().logError("unexpected exception", e);
return;
}
}
int remotePort = ((RequestEventExt) requestEvent).getRemotePort();
if (ListeningPoint.TCP.equalsIgnoreCase(transport)) {
remotePort = ((MessageExt) requestEvent.getRequest()).getTopmostViaHeader().getPort();
}
((ClusteredSipStack) sipStack).getStackLogger().logDebug("remotePort = " + remotePort);
final Request request = (Request) requestEvent.getRequest().clone();
((SipURI) request.getRequestURI()).setPort(5070);
request.removeLast(RouteHeader.NAME);
RouteHeader routeHeader = (RouteHeader) request.getHeader(RouteHeader.NAME);
if (routeHeader != null && (((SipURI) routeHeader.getAddress().getURI()).getPort() == 5080 || ((SipURI) routeHeader.getAddress().getURI()).getPort() == 5081)) {
request.removeFirst(RouteHeader.NAME);
}
request.addHeader(headerFactory.createViaHeader(ipAddress, myPort, transport, null));
final ClientTransaction ct = sipProvider.getNewClientTransaction(request);
ct.sendRequest();
} catch (Exception e) {
((SipStackImpl) sipStack).getStackLogger().logError("unexpected exception", e);
}
}
use of gov.nist.javax.sip.RequestEventExt in project jain-sip.ha by RestComm.
the class SimpleB2BUAHandler method processAck.
public void processAck(RequestEvent requestEvent) {
int remotePort = ((RequestEventExt) requestEvent).getRemotePort();
if (ListeningPoint.TCP.equalsIgnoreCase(transport)) {
remotePort = ((MessageExt) requestEvent.getRequest()).getTopmostViaHeader().getPort();
}
((ClusteredSipStack) sipStack).getStackLogger().logDebug("remotePort = " + remotePort);
try {
if (!sendAckOn2xx) {
Dialog dialog = null;
if (remotePort == 5070) {
dialog = getIncomingDialog();
}
if (remotePort == 5050 || remotePort == 5060 || remotePort == 5065) {
storeIncomingDialogId(requestEvent.getDialog().getDialogId());
dialog = getOutgoingDialog();
}
final Request ack = dialog.createAck(((MessageExt) requestEvent.getRequest()).getCSeqHeader().getSeqNumber());
dialog.sendAck(ack);
} else {
if (myPort == 5080 && getIncomingDialogId() == null) {
storeIncomingDialogId(requestEvent.getDialog().getDialogId());
}
if (remotePort == 5050 || remotePort == 5060 || remotePort == 5065) {
storeIncomingDialogId(requestEvent.getDialog().getDialogId());
}
}
if (createInviteOnAck) {
createInviteOnAck = false;
Request request = getIncomingDialog().createRequest("INVITE");
final ClientTransaction ct = sipProvider.getNewClientTransaction(request);
getIncomingDialog().sendRequest(ct);
}
} catch (Exception e) {
((SipStackImpl) sipStack).getStackLogger().logError("unexpected exception", e);
}
}
use of gov.nist.javax.sip.RequestEventExt in project jain-sip.ha by RestComm.
the class SimpleB2BUAHandler method processBye.
public void processBye(RequestEvent requestEvent) {
try {
int remotePort = ((RequestEventExt) requestEvent).getRemotePort();
if (ListeningPoint.TCP.equalsIgnoreCase(transport)) {
remotePort = ((MessageExt) requestEvent.getRequest()).getTopmostViaHeader().getPort();
}
((ClusteredSipStack) sipStack).getStackLogger().logDebug("remotePort = " + remotePort);
requestEvent.getServerTransaction().sendResponse(messageFactory.createResponse(200, requestEvent.getRequest()));
Dialog dialog = getOutgoingDialog();
if (remotePort == 5060 || remotePort == 5065) {
dialog = getIncomingDialog();
}
Request request = dialog.createRequest(Request.BYE);
final ClientTransaction ct = sipProvider.getNewClientTransaction(request);
dialog.sendRequest(ct);
} catch (Exception e) {
((SipStackImpl) sipStack).getStackLogger().logError("unexpected exception", e);
}
}
use of gov.nist.javax.sip.RequestEventExt in project jain-sip.ha by RestComm.
the class SimpleStatefulProxy method processAck.
public void processAck(RequestEvent requestEvent) {
int remotePort = ((RequestEventExt) requestEvent).getRemotePort();
if (ListeningPoint.TCP.equalsIgnoreCase(transport)) {
remotePort = ((MessageExt) requestEvent.getRequest()).getTopmostViaHeader().getPort();
}
((ClusteredSipStack) sipStack).getStackLogger().logDebug("remotePort = " + remotePort);
try {
final Request ack = (Request) requestEvent.getRequest().clone();
String branchId = getClientTransactionId();
ack.addHeader(headerFactory.createViaHeader(ipAddress, myPort, transport, branchId));
((SipURI) ack.getRequestURI()).setPort(getClientTransactionPort());
ack.removeLast(RouteHeader.NAME);
RouteHeader routeHeader = (RouteHeader) ack.getHeader(RouteHeader.NAME);
if (routeHeader != null && (((SipURI) routeHeader.getAddress().getURI()).getPort() == 5080 || ((SipURI) routeHeader.getAddress().getURI()).getPort() == 5081)) {
ack.removeFirst(RouteHeader.NAME);
}
sipProvider.sendRequest(ack);
} catch (Exception e) {
((SipStackImpl) sipStack).getStackLogger().logError("unexpected exception", e);
}
}
Aggregations