Search in sources :

Example 26 with SipProvider

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;
}
Also used : Inet6Address(java.net.Inet6Address) ResponseEvent(javax.sip.ResponseEvent) InetAddress(java.net.InetAddress) SipProvider(javax.sip.SipProvider)

Example 27 with SipProvider

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;
}
Also used : RequestEvent(javax.sip.RequestEvent) Inet6Address(java.net.Inet6Address) InetAddress(java.net.InetAddress) SipProvider(javax.sip.SipProvider)

Example 28 with SipProvider

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;
}
Also used : ListeningPoint(javax.sip.ListeningPoint) SipProvider(javax.sip.SipProvider)

Example 29 with 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;
}
Also used : ListeningPoint(javax.sip.ListeningPoint) InvalidArgumentException(javax.sip.InvalidArgumentException) ParseException(java.text.ParseException) PeerUnavailableException(javax.sip.PeerUnavailableException) SipException(javax.sip.SipException) IOException(java.io.IOException) SipProvider(javax.sip.SipProvider)

Example 30 with SipProvider

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;
}
Also used : ListeningPoint(javax.sip.ListeningPoint) InvalidArgumentException(javax.sip.InvalidArgumentException) ParseException(java.text.ParseException) PeerUnavailableException(javax.sip.PeerUnavailableException) SipException(javax.sip.SipException) IOException(java.io.IOException) SipProvider(javax.sip.SipProvider)

Aggregations

SipProvider (javax.sip.SipProvider)30 SipException (javax.sip.SipException)23 InvalidArgumentException (javax.sip.InvalidArgumentException)21 ParseException (java.text.ParseException)19 ListeningPoint (javax.sip.ListeningPoint)15 PeerUnavailableException (javax.sip.PeerUnavailableException)12 Response (javax.sip.message.Response)11 IOException (java.io.IOException)10 Request (javax.sip.message.Request)10 TransactionUnavailableException (javax.sip.TransactionUnavailableException)9 ServerTransaction (javax.sip.ServerTransaction)7 TooManyListenersException (java.util.TooManyListenersException)6 Dialog (javax.sip.Dialog)6 ObjectInUseException (javax.sip.ObjectInUseException)6 ContactHeader (javax.sip.header.ContactHeader)6 ToHeader (javax.sip.header.ToHeader)6 EventHeader (javax.sip.header.EventHeader)5 ViaHeader (javax.sip.header.ViaHeader)5 ClientTransaction (javax.sip.ClientTransaction)4 TransactionDoesNotExistException (javax.sip.TransactionDoesNotExistException)4