My Activity code:
public String getValue(JSONObject data) {
String value;
socket.emit("request", data, new Ack() {
@Override
public void call(Object... args) {
value = (String) args[1]; // how to wait for this value?
});
return value;
}
How do I wait for the value
that came from the socket.io callback?
For anyone who's still facing for the same issue, use CompletableFuture
However, note that if answer wasn't provided, your code will be blocked until the answer would be provided by the server, however this is the question itself, so here you are