Search in sources :

Example 1 with SipSubscriptionListener

use of org.apache.camel.component.sip.listener.SipSubscriptionListener in project camel by apache.

the class SipSubscriber method doStart.

@Override
protected void doStart() throws Exception {
    super.doStart();
    Properties properties = configuration.createInitialProperties();
    sipStack = configuration.getSipFactory().createSipStack(properties);
    configuration.parseURI();
    sipSubscriptionListener = new SipSubscriptionListener(this);
    ListeningPoint listeningPoint = sipStack.createListeningPoint(configuration.getFromHost(), Integer.valueOf(configuration.getFromPort()).intValue(), configuration.getTransport());
    configuration.setListeningPoint(listeningPoint);
    provider = sipStack.createSipProvider(configuration.getListeningPoint());
    provider.addSipListener(sipSubscriptionListener);
    if (configuration.getCallIdHeader() == null) {
        configuration.setCallIdHeader(provider.getNewCallId());
    }
    // Create the Subscription request to register with the presence agent and receive notifications.
    configuration.setCallIdHeader(provider.getNewCallId());
    Request request = configuration.createSipRequest(1, Request.SUBSCRIBE, configuration.getEventHeaderName());
    // Create the subscriber transaction from request.
    ClientTransaction subscriberTransactionId = provider.getNewClientTransaction(request);
    // Add an Event header for the subscription.
    request.addHeader(configuration.getEventHeader());
    subscriberDialog = subscriberTransactionId.getDialog();
    // Send the outgoing subscription request.
    subscriberTransactionId.sendRequest();
}
Also used : ClientTransaction(javax.sip.ClientTransaction) SipSubscriptionListener(org.apache.camel.component.sip.listener.SipSubscriptionListener) Request(javax.sip.message.Request) ListeningPoint(javax.sip.ListeningPoint) Properties(java.util.Properties)

Aggregations

Properties (java.util.Properties)1 ClientTransaction (javax.sip.ClientTransaction)1 ListeningPoint (javax.sip.ListeningPoint)1 Request (javax.sip.message.Request)1 SipSubscriptionListener (org.apache.camel.component.sip.listener.SipSubscriptionListener)1