Search in sources :

Example 1 with BroadcastListener

use of io.joynr.pubsub.publication.BroadcastListener in project joynr by bmwcarit.

the class PublicationManagerImpl method handleBroadcastSubscriptionRequest.

private void handleBroadcastSubscriptionRequest(String proxyParticipantId, String providerParticipantId, BroadcastSubscriptionRequest subscriptionRequest, ProviderContainer providerContainer) {
    logger.trace("adding broadcast publication: {}", subscriptionRequest);
    BroadcastListener broadcastListener = new BroadcastListenerImpl(subscriptionRequest.getSubscriptionId(), this);
    String broadcastName = subscriptionRequest.getSubscribedToName();
    providerContainer.getSubscriptionPublisher().registerBroadcastListener(broadcastName, broadcastListener);
    unregisterBroadcastListeners.put(subscriptionRequest.getSubscriptionId(), new UnregisterBroadcastListener(providerContainer.getSubscriptionPublisher(), broadcastName, broadcastListener));
    final String subscriptionId = subscriptionRequest.getSubscriptionId();
    SubscriptionQos subscriptionQos = subscriptionRequest.getQos();
    MessagingQos messagingQos = createMessagingQos(subscriptionQos);
    SubscriptionReply subscriptionReply = new SubscriptionReply(subscriptionId);
    dispatcher.sendSubscriptionReply(providerParticipantId, proxyParticipantId, subscriptionReply, messagingQos);
}
Also used : SubscriptionReply(joynr.SubscriptionReply) MessagingQos(io.joynr.messaging.MessagingQos) BroadcastListener(io.joynr.pubsub.publication.BroadcastListener) OnChangeSubscriptionQos(joynr.OnChangeSubscriptionQos) UnicastSubscriptionQos(joynr.UnicastSubscriptionQos) SubscriptionQos(io.joynr.pubsub.SubscriptionQos)

Example 2 with BroadcastListener

use of io.joynr.pubsub.publication.BroadcastListener in project joynr by bmwcarit.

the class SubscriptionPublisherTest method unregisteredBroadcastListenerNotCalledOnBroadcast.

@Test
public void unregisteredBroadcastListenerNotCalledOnBroadcast() throws Exception {
    String broadcastName = "mybroadcast";
    String value1 = "value1";
    String value2 = "value2";
    MySubscriptionPublisher subscriptionPublisher = new MySubscriptionPublisher();
    BroadcastListener broadcastListener = mock(BroadcastListener.class);
    subscriptionPublisher.registerBroadcastListener(broadcastName, broadcastListener);
    subscriptionPublisher.unregisterBroadcastListener(broadcastName, broadcastListener);
    List<BroadcastFilter> broadcastFilters = new ArrayList<BroadcastFilter>();
    BroadcastFilter broadcastFilter = mock(BroadcastFilter.class);
    broadcastFilters.add(broadcastFilter);
    subscriptionPublisher.fireBroadcast(broadcastName, broadcastFilters, value1, value2);
    verify(broadcastListener, never()).broadcastOccurred(eq(broadcastFilters), eq(value1), eq(value2));
}
Also used : BroadcastListener(io.joynr.pubsub.publication.BroadcastListener) ArrayList(java.util.ArrayList) BroadcastFilter(io.joynr.pubsub.publication.BroadcastFilter) Test(org.junit.Test)

Example 3 with BroadcastListener

use of io.joynr.pubsub.publication.BroadcastListener in project joynr by bmwcarit.

the class SubscriptionPublisherTest method registeredBroadcastListenerIsCalledOnBroadcast.

@Test
public void registeredBroadcastListenerIsCalledOnBroadcast() throws Exception {
    String broadcastName = "mybroadcast";
    String value1 = "value1";
    String value2 = "value2";
    MySubscriptionPublisher subscriptionPublisher = new MySubscriptionPublisher();
    BroadcastListener broadcastListener = mock(BroadcastListener.class);
    subscriptionPublisher.registerBroadcastListener(broadcastName, broadcastListener);
    List<BroadcastFilter> broadcastFilters = new ArrayList<BroadcastFilter>();
    BroadcastFilter broadcastFilter = mock(BroadcastFilter.class);
    broadcastFilters.add(broadcastFilter);
    subscriptionPublisher.fireBroadcast(broadcastName, broadcastFilters, value1, value2);
    verify(broadcastListener).broadcastOccurred(eq(broadcastFilters), eq(value1), eq(value2));
}
Also used : BroadcastListener(io.joynr.pubsub.publication.BroadcastListener) ArrayList(java.util.ArrayList) BroadcastFilter(io.joynr.pubsub.publication.BroadcastFilter) Test(org.junit.Test)

Aggregations

BroadcastListener (io.joynr.pubsub.publication.BroadcastListener)3 BroadcastFilter (io.joynr.pubsub.publication.BroadcastFilter)2 ArrayList (java.util.ArrayList)2 Test (org.junit.Test)2 MessagingQos (io.joynr.messaging.MessagingQos)1 SubscriptionQos (io.joynr.pubsub.SubscriptionQos)1 OnChangeSubscriptionQos (joynr.OnChangeSubscriptionQos)1 SubscriptionReply (joynr.SubscriptionReply)1 UnicastSubscriptionQos (joynr.UnicastSubscriptionQos)1