use of javax.sip.SipProvider in project load-balancer by RestComm.
the class SIPBalancerValveProcessor method processResponse.
public boolean processResponse(Response response, MessageChannel messageChannel) {
// catching all exceptions so it doesn't make JAIN SIP to fail
try {
SipProvider p = null;
Boolean isIpv6 = false;
InetAddress address = InetAddress.getByName(messageChannel.getHost());
if (address instanceof Inet6Address) {
isIpv6 = true;
p = balancerRunner.balancerContext.externalIpv6SipProvider;
if (messageChannel.getPort() != balancerRunner.balancerContext.getExternalPortByTransport(messageChannel.getTransport(), isIpv6)) {
if (balancerRunner.balancerContext.isTwoEntrypoints())
p = balancerRunner.balancerContext.internalIpv6SipProvider;
}
} else {
p = balancerRunner.balancerContext.externalSipProvider;
if (messageChannel.getPort() != balancerRunner.balancerContext.getExternalPortByTransport(messageChannel.getTransport(), isIpv6)) {
if (balancerRunner.balancerContext.isTwoEntrypoints())
p = balancerRunner.balancerContext.internalSipProvider;
}
}
ResponseEvent event = new ResponseEvent(new BalancerAppContent(p, isIpv6), null, null, response);
balancerRunner.balancerContext.forwarder.processResponse(event);
} catch (Exception e) {
logger.error("A Problem happened in the BalancerValve on response " + response, e);
return false;
}
return false;
}
use of javax.sip.SipProvider in project load-balancer by RestComm.
the class SIPBalancerValveProcessor method processRequest.
public boolean processRequest(SIPRequest request, MessageChannel messageChannel) {
// catching all exceptions so it doesn't make JAIN SIP to fail
try {
SipProvider p = null;
Boolean isIpv6 = false;
InetAddress address = InetAddress.getByName(messageChannel.getHost());
if (address instanceof Inet6Address) {
isIpv6 = true;
p = balancerRunner.balancerContext.externalIpv6SipProvider;
if (messageChannel.getPort() != balancerRunner.balancerContext.getExternalPortByTransport(messageChannel.getTransport(), isIpv6)) {
if (balancerRunner.balancerContext.isTwoEntrypoints())
p = balancerRunner.balancerContext.internalIpv6SipProvider;
}
} else {
p = balancerRunner.balancerContext.externalSipProvider;
if (messageChannel.getPort() != balancerRunner.balancerContext.getExternalPortByTransport(messageChannel.getTransport(), isIpv6)) {
if (balancerRunner.balancerContext.isTwoEntrypoints())
p = balancerRunner.balancerContext.internalSipProvider;
}
}
RequestEvent event = new RequestEvent(new BalancerAppContent(p, isIpv6), null, null, request);
balancerRunner.balancerContext.forwarder.processRequest(event);
} catch (Exception e) {
logger.error("A Problem happened in the BalancerValve on request " + request, e);
return false;
}
return false;
}
use of javax.sip.SipProvider in project load-balancer by RestComm.
the class SIPBalancerForwarder method createSipProviders.
private SipProvider createSipProviders(ArrayList<ListeningPoint> lps) throws ObjectInUseException, TransportAlreadySupportedException, TooManyListenersException {
SipProvider sipProvider = balancerRunner.balancerContext.sipStack.createSipProvider(lps.remove(0));
for (ListeningPoint lp : lps) sipProvider.addListeningPoint(lp);
sipProvider.addSipListener(this);
return sipProvider;
}
use of javax.sip.SipProvider in project jain-sip.ha by RestComm.
the class B2BUAEarlyDialogRecoveryOn2xxTest method stopSipStack.
public static void stopSipStack(SipStack sipStack, SipListener listener) {
Iterator<SipProvider> sipProviderIterator = sipStack.getSipProviders();
try {
while (sipProviderIterator.hasNext()) {
SipProvider sipProvider = sipProviderIterator.next();
ListeningPoint[] listeningPoints = sipProvider.getListeningPoints();
for (ListeningPoint listeningPoint : listeningPoints) {
sipProvider.removeListeningPoint(listeningPoint);
sipStack.deleteListeningPoint(listeningPoint);
listeningPoints = sipProvider.getListeningPoints();
}
sipProvider.removeSipListener(listener);
sipStack.deleteSipProvider(sipProvider);
sipProviderIterator = sipStack.getSipProviders();
}
} catch (Exception e) {
throw new IllegalStateException("Cant remove the listening points or sip providers", e);
}
sipStack.stop();
sipStack = null;
}
use of javax.sip.SipProvider in project jain-sip.ha by RestComm.
the class B2BUADialogRecoveryTest method stopSipStack.
public static void stopSipStack(SipStack sipStack, SipListener listener) {
Iterator<SipProvider> sipProviderIterator = sipStack.getSipProviders();
try {
while (sipProviderIterator.hasNext()) {
SipProvider sipProvider = sipProviderIterator.next();
ListeningPoint[] listeningPoints = sipProvider.getListeningPoints();
for (ListeningPoint listeningPoint : listeningPoints) {
sipProvider.removeListeningPoint(listeningPoint);
sipStack.deleteListeningPoint(listeningPoint);
listeningPoints = sipProvider.getListeningPoints();
}
sipProvider.removeSipListener(listener);
sipStack.deleteSipProvider(sipProvider);
sipProviderIterator = sipStack.getSipProviders();
}
} catch (Exception e) {
throw new IllegalStateException("Cant remove the listening points or sip providers", e);
}
sipStack.stop();
sipStack = null;
}
Aggregations