Created
April 3, 2013 13:21
-
-
Save moea/5301158 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import android.os.Handler; | |
import org.jeromq.ZMQ; | |
public class ZeroMQServer implements Runnable { | |
private final Handler uiThreadHandler; | |
public ZeroMQServer(Handler uiThreadHandler) { | |
this.uiThreadHandler = uiThreadHandler; | |
} | |
@Override | |
public void run() { | |
ZMQ.Context context = ZMQ.context(1); | |
ZMQ.Socket socket = context.socket(ZMQ.REP); | |
socket.bind("tcp://127.0.0.1:5555"); | |
while(!Thread.currentThread().isInterrupted()) { | |
byte[] msg = socket.recv(0); | |
uiThreadHandler.sendMessage( | |
Util.bundledMessage(uiThreadHandler, new String(msg))); | |
socket.send(Util.reverseInPlace(msg), 0); | |
} | |
socket.close(); | |
context.term(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I know this is quite dated but any idea what the Util class would be called now? Android seems to have no documentation on it.