Package eu.pursuit.core

Examples of eu.pursuit.core.Event


  public void run() {
    System.err.println("Processing the Events from the Thread");
    // Process the events...
    while(true){
      System.err.println("Publisher: Getting event...");
      Event event = publisher.getClient().getNextEvent();
      System.err.println("Publisher: Got event...");
      System.err.println(event.getType());
      byte[] id = event.getId();
      byte [] cat = publisher.getVideoPublisher().getCatalog();
      switch(event.getType()){
      case START_PUBLISH:
        // Is the event the catalog? Problem here!...
        if (Arrays.equals(id, cat)){
          // Get the catalog data
          String catData = publisher.getVideoPublisher().getCatalogNames();
View Full Code Here


  public void run() {
    System.err.println("Processing the Events from the Thread");
    // Process the events...
    mediaPlayer.playMedia("udp://@:6666");
    while(true){
      Event event = gui.getClient().getNextEvent();
//      System.err.println("Got " + event.getType());
      switch(event.getType()){
      case PUBLISHED_DATA:
        // Subscriber receives event.
        // is it the catalog?
        if (Arrays.equals(event.getId(), gui.getVideoSubscriber().getCatalog())){
//          Util.printBytes(event.getDataCopy()); 
          // populate the catalog list.
          gui.populateCatalogList(Util.getString(event.getDataCopy()));
          event.freeNativeBuffer();
          // finally unsubscribe to the catalog
          gui.getVideoSubscriber().unsubscribeCatalog();
        }else{
          // Is a video
          // get the packet and UDP it.
            try {
            byte [] buffer = event.getDataCopy();
              DatagramPacket p = new DatagramPacket(buffer, buffer.length, InetAddress.getLocalHost(), 6666);
              ds.send(p);
          } catch (SocketException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
          } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
          }
          event.freeNativeBuffer();
        }
        break;
      }
    }
  }
View Full Code Here

  public Event getNextEventDirect() {
    EventInternal e = new EventInternal();
    long event_ptr = c_nextEvent_direct(baPtr, e);   
   
    EventType type = EventType.getById(e.getType());
    Event retval = null;
    if(e.getData()!=null){
      retval = new Event(type, e.getId(), e.getData(), e.getData().capacity());
    }else{
      retval = new Event(type, e.getId());
    }
   
    retval.setNativeMemoryMappings(this, event_ptr);   
    return retval;
  }
View Full Code Here

   
    System.out.println("Publishing");
    client.publishItem(name, Strategy.NODE, null);
    System.out.println("done");
    System.out.println("waiting for events");
    Event event = client.getNextEvent();
    System.out.println("got a notification");
   
    byte [] payload = new byte[1000];
    Arrays.fill(payload, (byte)5);
    ByteBuffer buffer = ByteBuffer.allocateDirect(payload.length);
    buffer.put(payload);
    buffer.flip();   
    if(event.getType() == EventType.START_PUBLISH){   
      System.out.println("got event");
      for (int i = 0; i < TIMES; i++) {
        System.out.println("apcket "+i);
        client.publishData(event.getId(), payload, Strategy.NODE, null);
      }           
    }
    client.disconnect();
  }
View Full Code Here

   
    System.out.println("Subscribing");   
    System.out.println("waiting");
    long start = System.currentTimeMillis();
    for (int i = 0; i < Publisher.TIMES; i++) {
      Event event = client.getNextEvent();
      if(event.getType() == EventType.PUBLISHED_DATA){
        System.out.printf("Got notification %d and %d bytes\n",i, event.getDataLength());
        printbytes(event.getDataCopy());

        //make sure to free buffers
        event.freeNativeBuffer();
      }
    }
   
    long duration = System.currentTimeMillis() - start;
    System.out.printf("Duration %d\n", duration);
View Full Code Here

TOP

Related Classes of eu.pursuit.core.Event

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.