Remove temporary media debug messaging and proxy logging
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
// Maintainer-controlled web client version.
|
// Maintainer-controlled web client version.
|
||||||
// Format: YYYY.MM.DD Rn (example: 2026.02.20 R2)
|
// Format: YYYY.MM.DD Rn (example: 2026.02.20 R2)
|
||||||
window.CHGRID_WEB_VERSION = "2026.02.22 R141";
|
window.CHGRID_WEB_VERSION = "2026.02.22 R142";
|
||||||
// Optional display timezone for timestamps. Falls back to America/Detroit if unset/invalid.
|
// Optional display timezone for timestamps. Falls back to America/Detroit if unset/invalid.
|
||||||
window.CHGRID_TIME_ZONE = "America/Detroit";
|
window.CHGRID_TIME_ZONE = "America/Detroit";
|
||||||
|
|||||||
@@ -162,23 +162,13 @@ type RadioSpatialConfig = {
|
|||||||
export class RadioStationRuntime {
|
export class RadioStationRuntime {
|
||||||
private readonly sharedRadioSources = new Map<string, SharedRadioSource>();
|
private readonly sharedRadioSources = new Map<string, SharedRadioSource>();
|
||||||
private readonly itemRadioOutputs = new Map<string, ItemRadioOutput>();
|
private readonly itemRadioOutputs = new Map<string, ItemRadioOutput>();
|
||||||
private readonly lastStreamStatusAt = new Map<string, number>();
|
|
||||||
private layerEnabled = true;
|
private layerEnabled = true;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private readonly audio: AudioEngine,
|
private readonly audio: AudioEngine,
|
||||||
private readonly getSpatialConfig: (item: WorldItem) => RadioSpatialConfig,
|
private readonly getSpatialConfig: (item: WorldItem) => RadioSpatialConfig,
|
||||||
private readonly onStreamStatus?: (message: string) => void,
|
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
private reportStreamStatus(message: string, dedupeKey: string): void {
|
|
||||||
const now = Date.now();
|
|
||||||
const lastAt = this.lastStreamStatusAt.get(dedupeKey) ?? 0;
|
|
||||||
if (now - lastAt < 3000) return;
|
|
||||||
this.lastStreamStatusAt.set(dedupeKey, now);
|
|
||||||
this.onStreamStatus?.(message);
|
|
||||||
}
|
|
||||||
|
|
||||||
cleanup(itemId: string): void {
|
cleanup(itemId: string): void {
|
||||||
const output = this.itemRadioOutputs.get(itemId);
|
const output = this.itemRadioOutputs.get(itemId);
|
||||||
if (!output) return;
|
if (!output) return;
|
||||||
@@ -327,18 +317,6 @@ export class RadioStationRuntime {
|
|||||||
element.crossOrigin = 'anonymous';
|
element.crossOrigin = 'anonymous';
|
||||||
element.loop = true;
|
element.loop = true;
|
||||||
element.preload = 'none';
|
element.preload = 'none';
|
||||||
element.addEventListener('error', () => {
|
|
||||||
this.reportStreamStatus(
|
|
||||||
`Media stream failed: ${streamUrl}`,
|
|
||||||
`error:${streamUrl}`,
|
|
||||||
);
|
|
||||||
});
|
|
||||||
element.addEventListener('canplay', () => {
|
|
||||||
this.reportStreamStatus(
|
|
||||||
`Media stream ready: ${streamUrl}`,
|
|
||||||
`ready:${streamUrl}`,
|
|
||||||
);
|
|
||||||
});
|
|
||||||
const source = audioCtx.createMediaElementSource(element);
|
const source = audioCtx.createMediaElementSource(element);
|
||||||
void element.play().catch(() => undefined);
|
void element.play().catch(() => undefined);
|
||||||
const shared: SharedRadioSource = {
|
const shared: SharedRadioSource = {
|
||||||
|
|||||||
@@ -185,7 +185,7 @@ let outputMode = localStorage.getItem(AUDIO_OUTPUT_MODE_STORAGE_KEY) === 'mono'
|
|||||||
let connecting = false;
|
let connecting = false;
|
||||||
const messageBuffer: string[] = [];
|
const messageBuffer: string[] = [];
|
||||||
let messageCursor = -1;
|
let messageCursor = -1;
|
||||||
const radioRuntime = new RadioStationRuntime(audio, getItemSpatialConfig, (message) => updateStatus(message));
|
const radioRuntime = new RadioStationRuntime(audio, getItemSpatialConfig);
|
||||||
const itemEmitRuntime = new ItemEmitRuntime(audio, resolveIncomingSoundUrl, getItemSpatialConfig);
|
const itemEmitRuntime = new ItemEmitRuntime(audio, resolveIncomingSoundUrl, getItemSpatialConfig);
|
||||||
let internalClipboardText = '';
|
let internalClipboardText = '';
|
||||||
let replaceTextOnNextType = false;
|
let replaceTextOnNextType = false;
|
||||||
|
|||||||
@@ -12,27 +12,6 @@
|
|||||||
* - Provides same-origin endpoint for browser playback.
|
* - Provides same-origin endpoint for browser playback.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
ini_set('display_errors', '0');
|
|
||||||
ini_set('log_errors', '1');
|
|
||||||
error_reporting(E_ALL);
|
|
||||||
|
|
||||||
function proxy_log_path()
|
|
||||||
{
|
|
||||||
$tmp = sys_get_temp_dir();
|
|
||||||
if (!is_string($tmp) || $tmp === '') {
|
|
||||||
$tmp = '/tmp';
|
|
||||||
}
|
|
||||||
return rtrim($tmp, '/\\') . '/chgrid_media_proxy_error.log';
|
|
||||||
}
|
|
||||||
|
|
||||||
ini_set('error_log', proxy_log_path());
|
|
||||||
|
|
||||||
function proxy_debug_log($message)
|
|
||||||
{
|
|
||||||
$line = date('c') . ' ' . $message . PHP_EOL;
|
|
||||||
@file_put_contents(proxy_log_path(), $line, FILE_APPEND);
|
|
||||||
}
|
|
||||||
|
|
||||||
$GLOBALS['CHGRID_PROXY_HEADERS_SENT'] = false;
|
$GLOBALS['CHGRID_PROXY_HEADERS_SENT'] = false;
|
||||||
$GLOBALS['CHGRID_PROXY_STATUS'] = 200;
|
$GLOBALS['CHGRID_PROXY_STATUS'] = 200;
|
||||||
$GLOBALS['CHGRID_PROXY_UP_HEADERS'] = array();
|
$GLOBALS['CHGRID_PROXY_UP_HEADERS'] = array();
|
||||||
@@ -113,17 +92,6 @@ function proxy_write_callback($ch, $chunk)
|
|||||||
return $len;
|
return $len;
|
||||||
}
|
}
|
||||||
|
|
||||||
register_shutdown_function(function () {
|
|
||||||
$e = error_get_last();
|
|
||||||
if (!$e) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
proxy_debug_log('FATAL: ' . json_encode($e));
|
|
||||||
});
|
|
||||||
|
|
||||||
proxy_debug_log('START method=' . (isset($_SERVER['REQUEST_METHOD']) ? $_SERVER['REQUEST_METHOD'] : 'unknown') . ' uri=' . (isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : ''));
|
|
||||||
header('X-ChatGrid-MediaProxy: reached');
|
|
||||||
|
|
||||||
function set_status($code)
|
function set_status($code)
|
||||||
{
|
{
|
||||||
$map = array(
|
$map = array(
|
||||||
@@ -262,7 +230,6 @@ $ok = curl_exec($ch);
|
|||||||
if ($ok === false) {
|
if ($ok === false) {
|
||||||
$err = curl_error($ch);
|
$err = curl_error($ch);
|
||||||
curl_close($ch);
|
curl_close($ch);
|
||||||
proxy_debug_log('ERROR curl_exec failed: ' . $err);
|
|
||||||
send_text(502, 'upstream fetch failed: ' . $err);
|
send_text(502, 'upstream fetch failed: ' . $err);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user