parent
d12e1047f1
commit
9170db9792
|
@ -220,20 +220,29 @@ public class BinaryProtocol {
|
||||||
// FileLog.rlog("queue: " + LinkManager.COMMUNICATION_QUEUE.toString());
|
// FileLog.rlog("queue: " + LinkManager.COMMUNICATION_QUEUE.toString());
|
||||||
if (linkManager.COMMUNICATION_QUEUE.isEmpty() && linkManager.getNeedPullData()) {
|
if (linkManager.COMMUNICATION_QUEUE.isEmpty() && linkManager.getNeedPullData()) {
|
||||||
linkManager.submit(new Runnable() {
|
linkManager.submit(new Runnable() {
|
||||||
|
private final boolean verbose = false; // todo: programmatically detect run under gradle?
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
isGoodOutputChannels = requestOutputChannels();
|
isGoodOutputChannels = requestOutputChannels();
|
||||||
|
if (verbose)
|
||||||
|
System.out.println("requestOutputChannels " + isGoodOutputChannels);
|
||||||
if (isGoodOutputChannels)
|
if (isGoodOutputChannels)
|
||||||
HeartBeatListeners.onDataArrived();
|
HeartBeatListeners.onDataArrived();
|
||||||
binaryProtocolLogger.compositeLogic(BinaryProtocol.this);
|
binaryProtocolLogger.compositeLogic(BinaryProtocol.this);
|
||||||
if (linkManager.isNeedPullText()) {
|
if (linkManager.isNeedPullText()) {
|
||||||
String text = requestPendingMessages();
|
String text = requestPendingTextMessages();
|
||||||
if (text != null)
|
if (text != null) {
|
||||||
textListener.onDataArrived((text + "\r\n").getBytes());
|
textListener.onDataArrived((text + "\r\n").getBytes());
|
||||||
|
if (verbose)
|
||||||
|
System.out.println("textListener");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (linkManager.isNeedPullLiveData()) {
|
if (linkManager.isNeedPullLiveData()) {
|
||||||
LiveDocsRegistry.LiveDataProvider liveDataProvider = LiveDocsRegistry.getLiveDataProvider();
|
LiveDocsRegistry.LiveDataProvider liveDataProvider = LiveDocsRegistry.getLiveDataProvider();
|
||||||
LiveDocsRegistry.INSTANCE.refresh(liveDataProvider);
|
LiveDocsRegistry.INSTANCE.refresh(liveDataProvider);
|
||||||
|
if (verbose)
|
||||||
|
System.out.println("Got livedata");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -564,13 +573,19 @@ public class BinaryProtocol {
|
||||||
return text.getBytes();
|
return text.getBytes();
|
||||||
}
|
}
|
||||||
|
|
||||||
private String requestPendingMessages() {
|
private String requestPendingTextMessages() {
|
||||||
if (isClosed)
|
if (isClosed)
|
||||||
return null;
|
return null;
|
||||||
try {
|
try {
|
||||||
byte[] response = executeCommand(Fields.TS_GET_TEXT, "text");
|
byte[] response = executeCommand(Fields.TS_GET_TEXT, "text");
|
||||||
if (response != null && response.length == 1)
|
if (response == null) {
|
||||||
|
log.error("ERROR: TS_GET_TEXT failed");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
if (response != null && response.length == 1) {
|
||||||
|
// todo: what is this sleep doing exactly?
|
||||||
Thread.sleep(100);
|
Thread.sleep(100);
|
||||||
|
}
|
||||||
return new String(response, 1, response.length - 1);
|
return new String(response, 1, response.length - 1);
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
log.error(e.toString());
|
log.error(e.toString());
|
||||||
|
|
Loading…
Reference in New Issue