Files
whatsapp/test_sse_debug.sh
T
2026-01-27 23:56:49 -05:00

30 lines
1.1 KiB
Bash
Executable File

#!/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