This commit is contained in:
Lizandro Guarnizo
2026-01-27 15:01:32 -05:00
parent 1f224044f7
commit 6e3f375f91
3 changed files with 30 additions and 12 deletions
+7 -5
View File
@@ -79,16 +79,18 @@ try {
error_log('SSE: Conexión en modo global (sin autenticación específica)');
}
$db = Database::getInstance();
// Enviar evento inicial de conexión
error_log("SSE: Nueva conexión establecida (userId: {$userId})");
// IMPORTANTE: Enviar evento connected ANTES de hacer cualquier otra cosa
error_log("SSE: Enviando evento connected (userId: {$userId})");
sendSSEEvent('connected', [
'timestamp' => time(),
'user_id' => $userId,
'mode' => $authenticated ? 'authenticated' : 'global'
'mode' => $authenticated ? 'authenticated' : 'global',
'status' => 'ready'
]);
// Ahora sí, conectar a BD
$db = Database::getInstance();
// Obtener último timestamp conocido por el cliente
$lastEventId = $_SERVER['HTTP_LAST_EVENT_ID'] ?? null;
$lastCheck = time();
+8
View File
@@ -0,0 +1,8 @@
<?php
// Test simplísimo de SSE
header('Content-Type: text/event-stream');
header('Cache-Control: no-cache');
echo "event: test\n";
echo "data: {\"message\":\"works\"}\n\n";
flush();