Search in sources :

Example 1 with SipProvider

use of javax.sip.SipProvider in project Openfire by igniterealtime.

the class SimpleSession method sendRequest.

/**
	 * Sends a request with the specified request and transport.
	 * @param request   The request packet.
	 * @param transport The transport protocol used.
	 * @param dialog    The dialog for a persistent transaction.
	 *                  Leave it <code>null</code> if no dialog is associated with this request.
     * @throws javax.sip.SipException Unable to communicate.
	 */
@SuppressWarnings("unchecked")
private void sendRequest(Request request, String transport, Dialog dialog) throws SipException {
    for (Iterator sipProviders = sipStack.getSipProviders(); sipProviders.hasNext(); ) {
        SipProvider provider = (SipProvider) sipProviders.next();
        if (provider.getListeningPoint(transport) != null) {
            Log.debug("Sending packet:  \n" + request.toString() + "\n========\n");
            ClientTransaction transaction = provider.getNewClientTransaction(request);
            if (dialog != null)
                dialog.sendRequest(transaction);
            else
                transaction.sendRequest();
            return;
        }
    }
    Log.debug("SimpleSession(" + this.jid.getNode() + "):  No SipProvider found for that transport!");
}
Also used : ClientTransaction(javax.sip.ClientTransaction) Iterator(java.util.Iterator) SipProvider(javax.sip.SipProvider)

Example 2 with SipProvider

use of javax.sip.SipProvider in project camel by apache.

the class SipSubscriptionListener method processNotify.

public synchronized void processNotify(RequestEvent requestEvent, ServerTransaction serverTransactionId) {
    LOG.debug("Notification received at Subscriber");
    SipProvider provider = (SipProvider) requestEvent.getSource();
    Request notify = requestEvent.getRequest();
    try {
        if (serverTransactionId == null) {
            LOG.info("ServerTransaction is null. Creating new Server transaction");
            serverTransactionId = provider.getNewServerTransaction(notify);
        }
        Dialog dialog = serverTransactionId.getDialog();
        if (dialog != subscriberDialog) {
            forkedDialog = dialog;
        }
        //Dispatch the response along the route
        dispatchExchange(notify.getContent());
        // Send back an success response
        Response response = sipSubscriber.getConfiguration().getMessageFactory().createResponse(200, notify);
        response.addHeader(sipSubscriber.getConfiguration().getContactHeader());
        serverTransactionId.sendResponse(response);
        SubscriptionStateHeader subscriptionState = (SubscriptionStateHeader) notify.getHeader(SubscriptionStateHeader.NAME);
        // Subscription is terminated?
        if (subscriptionState.getState().equalsIgnoreCase(SubscriptionStateHeader.TERMINATED)) {
            LOG.info("Subscription state is terminated. Deleting the current dialog");
            dialog.delete();
        }
    } catch (Exception e) {
        LOG.error("Exception thrown during Notify processing in the SipSubscriptionListener.", e);
    }
}
Also used : Response(javax.sip.message.Response) Dialog(javax.sip.Dialog) SubscriptionStateHeader(javax.sip.header.SubscriptionStateHeader) Request(javax.sip.message.Request) CamelException(org.apache.camel.CamelException) SipProvider(javax.sip.SipProvider)

Example 3 with SipProvider

use of javax.sip.SipProvider in project XobotOS by xamarin.

the class SipSessionGroup method reset.

synchronized void reset(String localIp) throws SipException, IOException {
    mLocalIp = localIp;
    if (localIp == null)
        return;
    SipProfile myself = mLocalProfile;
    SipFactory sipFactory = SipFactory.getInstance();
    Properties properties = new Properties();
    properties.setProperty("javax.sip.STACK_NAME", getStackName());
    properties.setProperty("gov.nist.javax.sip.THREAD_POOL_SIZE", THREAD_POOL_SIZE);
    String outboundProxy = myself.getProxyAddress();
    if (!TextUtils.isEmpty(outboundProxy)) {
        Log.v(TAG, "outboundProxy is " + outboundProxy);
        properties.setProperty("javax.sip.OUTBOUND_PROXY", outboundProxy + ":" + myself.getPort() + "/" + myself.getProtocol());
    }
    SipStack stack = mSipStack = sipFactory.createSipStack(properties);
    try {
        SipProvider provider = stack.createSipProvider(stack.createListeningPoint(localIp, allocateLocalPort(), myself.getProtocol()));
        provider.addSipListener(this);
        mSipHelper = new SipHelper(stack, provider);
    } catch (InvalidArgumentException e) {
        throw new IOException(e.getMessage());
    } catch (TooManyListenersException e) {
        // must never happen
        throw new SipException("SipSessionGroup constructor", e);
    }
    Log.d(TAG, " start stack for " + myself.getUriString());
    stack.start();
    mCallReceiverSession = null;
    mSessionMap.clear();
    resetExternalAddress();
}
Also used : TooManyListenersException(java.util.TooManyListenersException) InvalidArgumentException(javax.sip.InvalidArgumentException) SipProfile(android.net.sip.SipProfile) SipFactory(javax.sip.SipFactory) SipStack(javax.sip.SipStack) IOException(java.io.IOException) Properties(java.util.Properties) SipException(javax.sip.SipException) SipProvider(javax.sip.SipProvider)

Example 4 with SipProvider

use of javax.sip.SipProvider in project jain-sip.ha by RestComm.

the class B2BUAEarlyDialogRecoveryOn2xxTestNotEnabled 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 5 with SipProvider

use of javax.sip.SipProvider in project jain-sip.ha by RestComm.

the class B2BUAEarlyDialogRecoveryOn1xxTCPTest 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) {
                try {
                    sipProvider.removeListeningPoint(listeningPoint);
                    sipStack.deleteListeningPoint(listeningPoint);
                } catch (Exception e) {
                    System.err.println("Cant remove the listening points or sip providers");
                }
                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