Reduce logs for web previews (#5854)

Do not show in changelog
This commit is contained in:
Clément Pasteau
2023-11-03 16:29:37 +01:00
committed by GitHub
parent decd96c52f
commit fcbc538c30
2 changed files with 36 additions and 33 deletions

View File

@@ -379,7 +379,8 @@ namespace gdjs {
// Check origin of message.
if (checkOrigin && !allowedOrigins.includes(event.origin)) {
throw new Error(`Unexpected origin: ${event.origin}`);
// Automatic authentication message ignored: wrong origin. Return silently.
return;
}
// Check that message is not malformed.
if (!event.data.id) {

View File

@@ -167,40 +167,42 @@ namespace gdjs {
protected handleCommand(data: any) {
const that = this;
const runtimeGame = this._runtimegame;
if (data && data.command) {
if (data.command === 'play') {
runtimeGame.pause(false);
} else if (data.command === 'pause') {
runtimeGame.pause(true);
that.sendRuntimeGameDump();
} else if (data.command === 'refresh') {
that.sendRuntimeGameDump();
} else if (data.command === 'set') {
that.set(data.path, data.newValue);
} else if (data.command === 'call') {
that.call(data.path, data.args);
} else if (data.command === 'profiler.start') {
runtimeGame.startCurrentSceneProfiler(function (stoppedProfiler) {
that.sendProfilerOutput(
stoppedProfiler.getFramesAverageMeasures(),
stoppedProfiler.getStats()
);
that.sendProfilerStopped();
});
that.sendProfilerStarted();
} else if (data.command === 'profiler.stop') {
runtimeGame.stopCurrentSceneProfiler();
} else if (data.command === 'hotReload') {
that._hotReloader.hotReload().then((logs) => {
that.sendHotReloaderLogs(logs);
});
} else {
logger.info(
'Unknown command "' + data.command + '" received by the debugger.'
if (!data || !data.command) {
// Not a command that's meant to be handled by the debugger, return silently to
// avoid polluting the console.
return;
}
if (data.command === 'play') {
runtimeGame.pause(false);
} else if (data.command === 'pause') {
runtimeGame.pause(true);
that.sendRuntimeGameDump();
} else if (data.command === 'refresh') {
that.sendRuntimeGameDump();
} else if (data.command === 'set') {
that.set(data.path, data.newValue);
} else if (data.command === 'call') {
that.call(data.path, data.args);
} else if (data.command === 'profiler.start') {
runtimeGame.startCurrentSceneProfiler(function (stoppedProfiler) {
that.sendProfilerOutput(
stoppedProfiler.getFramesAverageMeasures(),
stoppedProfiler.getStats()
);
}
that.sendProfilerStopped();
});
that.sendProfilerStarted();
} else if (data.command === 'profiler.stop') {
runtimeGame.stopCurrentSceneProfiler();
} else if (data.command === 'hotReload') {
that._hotReloader.hotReload().then((logs) => {
that.sendHotReloaderLogs(logs);
});
} else {
logger.info('Debugger received a message with badly formatted data.');
logger.info(
'Unknown command "' + data.command + '" received by the debugger.'
);
}
}