Files
tell/plugins/TestZMQ.java
gac-S_Changer bdf5049f96 Creation
2018-12-03 12:17:40 +01:00

27 lines
907 B
Java

/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
/**
*
* @author gac-S_Changer
*/
public class TestZMQ {
public static void main(String[] args) {
String server = "raspberrypi:5556";
org.zeromq.ZMQ.Context context = org.zeromq.ZMQ.context(1);
org.zeromq.ZMQ.Socket subscriber = context.socket(org.zeromq.ZMQ.SUB);
subscriber.connect("tcp://" + server);
subscriber.subscribe("Status".getBytes());
while (!Thread.currentThread().isInterrupted()) {
String type = subscriber.recvStr();
String contents = subscriber.recvStr();
System.out.println(type + " : " + contents);
}
subscriber.close();
context.term();
}
}