/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package avis.test.hello;

import org.avis.client.Elvin;
import org.avis.client.GeneralNotificationEvent;
import org.avis.client.GeneralNotificationListener;
import org.avis.client.NotificationEvent;
import org.avis.client.NotificationListener;
import org.avis.client.Subscription;

/**
 *
 * @author dhaval
 */
public class Subscriber {

    private Elvin elvin;

    public Subscriber() throws Exception{
        elvin = new Elvin("elvin://localhost");
    }

    public void startSubscriber() throws Exception{
        Subscription subscription = elvin.subscribe("Name == 'Dhaval'");
        subscription.addListener(new NotificationListener() {

            public void notificationReceived(NotificationEvent e) {
                System.out.println("Time on Dhaval's machine is " + e.notification.getString("Time") + " with counter " + e.notification.getInt("Counter"));
            }
        });
    }

    public static void main(String[] args) throws Exception{
        new Subscriber().startSubscriber();
    }
}
