Playground API
DocsStatsBlogStudio
Documentation Tree
Technical BlogFeature Deep Dives
  • Introduction
  • Quickstart
    5 min
  • How It Works
  • Recipes & Cookbooks
  • Platform Comparisons
  • Real-World Showcase
  • Interactive Studio
    Studio
  • GraphiQL IDE
    IDE
  • Session Quotas & Activity
  • Network Chaos Simulator
  • Atomic Sandbox Reset
  • Overview & Models
    Hub
  • Users Resource
  • Posts Resource
  • Comments Resource
  • Todos Resource
  • Custom Collections
    Custom
  • Multipart File Uploads
    Upload
  • Dynamic SVG Avatars
    SVG
  • Image Thumbnails
    CDN
  • Relational Filtering
  • Full-Text Search
  • Dynamic Sorting
  • Offset Pagination
  • Cursor Pagination
    Scroll
  • CSV & Excel Export & Import
    IO
  • Custom Collections
    CRUD
  • Overview & Architecture
    Hub
  • JWT Auth Flow
  • Refresh Token Rotation
    Mutex
  • RBAC Permission Matrix
    Roles
  • Expiry Simulation
  • Clock Skew Drift
  • Password Recovery Loop
  • Dual-Mode Sandboxing
  • GraphiQL IDE
    IDE
  • Relational Queries
  • Stateful Mutations
  • Realtime Subscriptions
  • Overview & Flowcharts
    Hub
  • Hosted Checkout
    Stripe
  • Payment Intents API
  • 3DS Challenge Modal
    Modal
  • Customers Vault
  • Charges & Refunds
  • Test Cards Catalog
  • Overview & Channels
    Hub
  • Virtual Email Mailbox
    Mailtrap
  • Virtual SMS Terminal
    Phone
  • In-App Notifications
  • Message Dispatcher
  • Realtime Studio
    Studio
  • Native WebSocket (/ws)
  • Socket.io Gateway
  • Presence & Echo Bot
  • Server-Sent Events (SSE)
    SSE
  • Analytics Telemetry
  • Webhook Subscriptions
  • HMAC SHA-256 Signatures
  • Delivery Logs
  • Manual Retry Simulator
  • Network Latency Delay
  • HTTP Status Codes
  • Rate-Limit Simulator
    429
  • Flaky Network & Jitter
    Chaos
  • Session Quotas & Activity
  • JSON Snapshots
    JSON
  • Headless CI/CD Testing
    CI
  • Mobile QR Code Sync
  • System Metrics & Health
  • Atomic Sandbox Reset
  • Official TypeScript SDK
  • Multi-Language Generators
  • DevTools Extension
  • OpenAPI 3.1 Spec
    JSON
  • Postman Collection v2.1
  • Bruno Collection
  • Insomnia Workspace
  • TypeScript .d.ts
    .d.ts
  • AI Prompt Rules
    Rules
  • Context Index (llms.txt)
  • Full Schema (llms-full.txt)
  • Manifest (product.json)
  • All Feature Articles
    Blog
  • React CRUD Without Backend
    Deep Dive
  • Why Static APIs Fail
  • Mocking Stateful Auth
  • WebSockets & SSE Guide
Technical Blog
Articles

In-depth articles explaining stateful mock APIs, WebSockets, payments, and frontend resilience.

Read Articles
PreviousSocket.io Gateway
NextServer-Sent Events (SSE)
Realtime & WebSockets

Presence Tracking & Echo Bots

Simulate real-time user presence (online/away/offline), keystroke typing indicators, and automated response echo bots in collaborative multi-user apps. Both the Native WebSocket and Socket.io gateways synchronize presence events across shared rooms.

Interactive Presence & Echo Bot Visualizer

Select a simulated participant, toggle presence state or keystroke activity, and inspect the resulting JSON frames:

A

Alice

Room #general•online
Alice is typing...
Dispatched Typing / Presence Frame
1
{
2
"type": "typing",
3
"room": "general",
4
"user": "Alice",
5
"isTyping": true,
6
"status": "online"
7
}
Automated Echo Bot Reply Frame (@bot)
1
{
2
"type": "message",
3
"id": "msg-bot-8e99a1-cb42",
4
"room": "support",
5
"sender_id": "bot_assistant",
6
"sender_name": "Support Bot",
7
"text": "Received your query: \"@bot what is the current server time?\". All systems operational.",
8
"created_at": "2026-09-29T12:00:00.000Z"
9
}

Presence State Machine Specification

Standard presence lifecycle transitions supported across room subscribers:

StateIndicatorTrigger ConditionDescription
onlineSocket connection activeClient is connected and actively interacting with the workspace.
idle300s keystroke inactivityConnection remains alive but no typing or click activity detected.
awayExplicit status updateUser manually toggled status or switched browser tab visibility.
offlineSocket disconnect / timeoutTCP connection closed or heartbeat missed. Client removed from room set.

Client Debounced Typing Hook

Prevent network flooding by debouncing typing indicators with a 1500ms timeout window:

useTypingIndicator.ts
1
// React 19 Custom Typing Indicator Debouncer Hook
2
import { useState, useRef, useCallback, useEffect } from 'react';
3
4
export function useTypingIndicator(socket: any, room = 'general', debounceMs = 1500) {
5
const [isTyping, setIsTyping] = useState(false);
6
const timeoutRef = useRef<NodeJS.Timeout | null>(null);
7
8
const notifyTyping = useCallback(() => {
9
if (!isTyping) {
10
setIsTyping(true);
11
socket?.emit('typing', { room, isTyping: true });
12
}
13
14
if (timeoutRef.current) clearTimeout(timeoutRef.current);
15
16
timeoutRef.current = setTimeout(() => {
17
setIsTyping(false);
18
socket?.emit('typing', { room, isTyping: false });
19
}, debounceMs);
20
}, [socket, room, isTyping, debounceMs]);
21
22
useEffect(() => {
23
return () => {
24
if (timeoutRef.current) clearTimeout(timeoutRef.current);
25
};
26
}, []);
27
28
return { notifyTyping, isTyping };
29
}