FlatBuffer_Receive.java
Go to the documentation of this file.
1 package grl.flatBufferTesting;
2 
3 import java.nio.ByteBuffer;
4 
5 import org.zeromq.ZMQ;
6 
8 import grl.flatbuffer.Vector3d;
9 
10 public class FlatBuffer_Receive {
11  static final int NUM_MSG = 10;
12  static final String ADDRESS = "tcp://127.0.0.1:9998";
13  public static void main(String[] args) throws Exception {
14 
15  ZMQ.Context context = ZMQ.context(1);
16  ZMQ.Socket subscriber = context.socket(ZMQ.DEALER);
17 
18  subscriber.connect("tcp://127.0.0.1:9998");
19  subscriber.setRcvHWM(1000000);
20  System.out.println("Connected to: "+ADDRESS);
21 
22  int c = 0;
23 
24  while (true) {
25  byte[] data = subscriber.recv();
26  ByteBuffer bb = ByteBuffer.wrap(data);
28  Vector3d position = controlpoint.position();
29  System.out.println("Position "+c+":");
30  System.out.println(position);
31  if (c >= NUM_MSG) {
32  break;
33  }
34  }
35  subscriber.close();
36  Thread.sleep(1000);
37  context.term();
38  System.exit(1);
39  }
40 }