#!/bin/bash

# Test script to simulate typing indicators from another device
# Usage: ./test_typing.sh [start|stop]

SESSION_ID="ILUIWU2"
SENDER_ID="test-device-12345"
SENDER_NAME="Test Device"

if [ "$1" == "start" ]; then
    echo "Sending typing_start from $SENDER_NAME..."
    curl -s -X POST "http://crivello.dyndns.org:81/WebRTC/chat/typing_indicator.php" \
        -H "Content-Type: application/json" \
        -d "{\"sessionId\":\"$SESSION_ID\",\"senderId\":\"$SENDER_ID\",\"senderName\":\"$SENDER_NAME\",\"isTyping\":true}"
    echo ""
elif [ "$1" == "stop" ]; then
    echo "Sending typing_stop from $SENDER_NAME..."
    curl -s -X POST "http://crivello.dyndns.org:81/WebRTC/chat/typing_indicator.php" \
        -H "Content-Type: application/json" \
        -d "{\"sessionId\":\"$SESSION_ID\",\"senderId\":\"$SENDER_ID\",\"senderName\":\"$SENDER_NAME\",\"isTyping\":false}"
    echo ""
else
    echo "Usage: $0 [start|stop]"
    echo ""
    echo "This script simulates typing indicators from another device."
    echo "  start - Simulates someone starting to type"
    echo "  stop  - Simulates someone stopping typing"
    exit 1
fi

# Query current typing status
echo "Current typing status:"
curl -s "http://crivello.dyndns.org:81/WebRTC/chat/get_typing.php?sessionId=$SESSION_ID" | python3 -m json.tool
