Package eu.pursuit.client

Examples of eu.pursuit.client.BlackAdderClient


   
    String sharedObjPath = "lib/bindings/java-binding/jni/eu_pursuit_client_BlackadderWrapper.o";
   
    BlackadderWrapper.configureObjectFile(sharedObjPath);
   
    BlackAdderClient client = BlackAdderClient.getInstance();
    ScopeID rootScope = new ScopeID();
    ByteIdentifier rootScopeId = new ByteIdentifier((byte)0, 8);
    rootScope.addSegment(rootScopeId);
   
    client.publishRootScope(rootScopeId, Strategy.NODE, null);
   
    ByteIdentifier rid = new ByteIdentifier((byte)1, 8);
    ItemName name = new ItemName(rootScope, rid);
   
    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


  public static void main(String[] args) {
   
    String sharedObjPath = "lib/bindings/java-binding/jni/eu_pursuit_client_BlackadderWrapper.o";
    BlackadderWrapper.configureObjectFile(sharedObjPath);
   
    BlackAdderClient client = BlackAdderClient.getInstance();
    ScopeID rootScope = new ScopeID();
    rootScope.addSegment(new ByteIdentifier((byte)0, 8));
   
    ByteIdentifier rid = new ByteIdentifier((byte)1, 8);
    ItemName name = new ItemName(rootScope, rid);
   
    client.subscribeItem(name, Strategy.NODE, null);
   
    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);
    client.disconnect();
   
  }
View Full Code Here

TOP

Related Classes of eu.pursuit.client.BlackAdderClient

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.