mirror of
https://github.com/Eaglercraft-TeaVM-Fork/eagler-teavm.git
synced 2024-12-22 16:14:10 -08:00
Send less commands over Chrome RDP
This commit is contained in:
parent
a4b61bac19
commit
27d81c4fe6
|
@ -81,6 +81,7 @@ public class ChromeRDPDebugger implements JavaScriptDebugger, ChromeRDPExchangeC
|
||||||
private ConcurrentMap<Integer, ResponseHandler<Object>> responseHandlers = new ConcurrentHashMap<>();
|
private ConcurrentMap<Integer, ResponseHandler<Object>> responseHandlers = new ConcurrentHashMap<>();
|
||||||
private ConcurrentMap<Integer, CompletablePromise<Object>> promises = new ConcurrentHashMap<>();
|
private ConcurrentMap<Integer, CompletablePromise<Object>> promises = new ConcurrentHashMap<>();
|
||||||
private AtomicInteger messageIdGenerator = new AtomicInteger();
|
private AtomicInteger messageIdGenerator = new AtomicInteger();
|
||||||
|
private Promise<Void> runtimeEnabledPromise;
|
||||||
|
|
||||||
private List<JavaScriptDebuggerListener> getListeners() {
|
private List<JavaScriptDebuggerListener> getListeners() {
|
||||||
return new ArrayList<>(listeners);
|
return new ArrayList<>(listeners);
|
||||||
|
@ -121,7 +122,7 @@ public class ChromeRDPDebugger implements JavaScriptDebugger, ChromeRDPExchangeC
|
||||||
}
|
}
|
||||||
|
|
||||||
private Promise<Void> injectFunctions(int contextId) {
|
private Promise<Void> injectFunctions(int contextId) {
|
||||||
return callMethodAsync("Runtime.enable", void.class, null)
|
return enableRuntime()
|
||||||
.thenAsync(v -> {
|
.thenAsync(v -> {
|
||||||
CompileScriptCommand compileParams = new CompileScriptCommand();
|
CompileScriptCommand compileParams = new CompileScriptCommand();
|
||||||
compileParams.expression = "$dbg_class = function(obj) { return typeof obj === 'object' "
|
compileParams.expression = "$dbg_class = function(obj) { return typeof obj === 'object' "
|
||||||
|
@ -140,6 +141,13 @@ public class ChromeRDPDebugger implements JavaScriptDebugger, ChromeRDPExchangeC
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Promise<Void> enableRuntime() {
|
||||||
|
if (runtimeEnabledPromise == null) {
|
||||||
|
runtimeEnabledPromise = callMethodAsync("Runtime.enable", void.class, null);
|
||||||
|
}
|
||||||
|
return runtimeEnabledPromise;
|
||||||
|
}
|
||||||
|
|
||||||
private ChromeRDPExchangeListener exchangeListener = messageText -> {
|
private ChromeRDPExchangeListener exchangeListener = messageText -> {
|
||||||
callInExecutor(() -> receiveMessage(messageText)
|
callInExecutor(() -> receiveMessage(messageText)
|
||||||
.catchError(e -> {
|
.catchError(e -> {
|
||||||
|
@ -225,6 +233,9 @@ public class ChromeRDPDebugger implements JavaScriptDebugger, ChromeRDPExchangeC
|
||||||
}
|
}
|
||||||
|
|
||||||
private Promise<Void> scriptParsed(ScriptParsedNotification params) {
|
private Promise<Void> scriptParsed(ScriptParsedNotification params) {
|
||||||
|
if (params.getUrl() == null) {
|
||||||
|
return Promise.VOID;
|
||||||
|
}
|
||||||
if (scripts.putIfAbsent(params.getScriptId(), params.getUrl()) != null) {
|
if (scripts.putIfAbsent(params.getScriptId(), params.getUrl()) != null) {
|
||||||
return Promise.VOID;
|
return Promise.VOID;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user