#!/bin/bash # Script para probar conexiΓ³n SSE y ver eventos en tiempo real # Uso: ./test_sse_debug.sh echo "πŸ” Probando conexiΓ³n SSE..." echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" echo "" echo "Conectando a: http://localhost:8080/api/sse_events.php?token=demo_token" echo "" echo "πŸ“‘ Eventos recibidos (presiona Ctrl+C para salir):" echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" echo "" # Conectar al SSE y mostrar eventos con timestamp curl -N -H "Accept: text/event-stream" \ "http://localhost:8080/api/sse_events.php?token=demo_token&t=$(date +%s)" 2>&1 | \ while IFS= read -r line; do timestamp=$(date '+%H:%M:%S') if [[ "$line" == event:* ]]; then echo -e "\n\033[1;36m[$timestamp]\033[0m \033[1;33m${line}\033[0m" elif [[ "$line" == data:* ]]; then echo -e "\033[0;32m${line}\033[0m" elif [[ "$line" == id:* ]]; then echo -e "\033[0;90m${line}\033[0m" else [[ -n "$line" ]] && echo "$line" fi done