I am writing an Android application that receives a continuous stream of data. I've set up the connection inside a runnable like so:
Runnable runnable = new Runnable()
{
public void run()
{
ZMQ.Context context = ZMQ.context(1);
ZMQ.Socket subscriber = context.socket(ZMQ.SUB);
subscriber.connect("tcp://[IP]:[Port]");
TextView strDisplay = (TextView) findViewById(R.id.stringDisplay);
while (!Thread.currentThread ().isInterrupted ())
{
// Read message contents
Log.i("Output", "the while loop ran up to here");
//*HANGS ON THE LINE BELOW*
String testcase = subscriber.recvStr(0);
strDisplay.setText(testcase);
Log.i("Output", "The while loop completed");
}
Now, after much scouring of the interwebs, I've come to two conclusions:
1) that recvStr() is a blocking call that waits until it receives something. So that means it hasn't connected properly or something else
and
2) that I may have to set up a filter of some sort?
I can't figure out what I should do next. Any help from someone experienced with JeroMQ or Android server access is greatly appreciated
Possibly, you need to subscribe on topic you want to get from publisher or to subscribe on all topics after you made connection.
For example subscribing on single topic:
subscriber.subscribe("topic_to_get".getBytes());
Subscribing on every topic:
subscriber.subscribe("".getBytes());