Real-Time Features

Real-Time Features

Guides a coding agent in adding real-time features with WebSockets, Server-Sent Events or long polling: chat, live dashboards, notifications and collaborative editing.

Skill files7 files

references/

scripts/

templates/

SKILL.md105 lines
1
---
2
name: real-time-features
3
description: >
4
Implement real-time functionality using WebSockets, Server-Sent Events (SSE),
5
or long polling. Use when building chat applications, live dashboards,
6
collaborative editing, notifications, or any feature requiring instant
7
updates.
8
---
9
10
# Real-Time Features
11
12
## Table of Contents
13
14
- [Overview](#overview)
15
- [When to Use](#when-to-use)
16
- [Quick Start](#quick-start)
17
- [Reference Guides](#reference-guides)
18
- [Best Practices](#best-practices)
19
20
## Overview
21
22
Implement real-time bidirectional communication between clients and servers for instant data synchronization and live updates.
23
24
## When to Use
25
26
- Chat and messaging applications
27
- Live dashboards and analytics
28
- Collaborative editing (Google Docs-style)
29
- Real-time notifications
30
- Live sports scores or stock tickers
31
- Multiplayer games
32
- Live auctions or bidding systems
33
- IoT device monitoring
34
- Real-time location tracking
35
36
## Quick Start
37
38
Minimal working example:
39
40
```typescript
41
// server.ts
42
import WebSocket, { WebSocketServer } from "ws";
43
import { createServer } from "http";
44
45
interface Message {
46
type: "join" | "message" | "leave" | "typing";
47
userId: string;
48
username: string;
49
content?: string;
50
timestamp: number;
51
}
52
53
interface Client {
54
ws: WebSocket;
55
userId: string;
56
username: string;
57
roomId: string;
58
}
59
60
class ChatServer {
61
private wss: WebSocketServer;
62
private clients: Map<string, Client> = new Map();
63
private rooms: Map<string, Set<string>> = new Map();
64
65
constructor(port: number) {
66
// ... (see reference guides for full implementation)
67
```
68
69
## Reference Guides
70
71
Detailed implementations in the `references/` directory:
72
73
| Guide | Contents |
74
|---|---|
75
| [WebSocket Server (Node.js)](references/websocket-server-nodejs.md) | WebSocket Server (Node.js) |
76
| [WebSocket Client (React)](references/websocket-client-react.md) | WebSocket Client (React) |
77
| [Server-Sent Events (SSE)](references/server-sent-events-sse.md) | Server-Sent Events (SSE) |
78
| [Socket.IO (Production-Ready)](references/socketio-production-ready.md) | Socket.IO (Production-Ready) |
79
80
## Best Practices
81
82
### ✅ DO
83
84
- Implement reconnection logic with exponential backoff
85
- Use heartbeat/ping-pong to detect dead connections
86
- Validate and sanitize all messages
87
- Implement authentication and authorization
88
- Handle connection limits and rate limiting
89
- Use compression for large payloads
90
- Implement proper error handling
91
- Monitor connection health
92
- Use rooms/channels for targeted messaging
93
- Implement graceful shutdown
94
95
### ❌ DON'T
96
97
- Send sensitive data without encryption
98
- Keep connections open indefinitely without cleanup
99
- Broadcast to all users when targeted messaging suffices
100
- Ignore connection state management
101
- Send large payloads frequently
102
- Skip message validation
103
- Forget about mobile/unstable connections
104
- Ignore scaling considerations
105

© AJ Geddes · MIT · source · posted by @OpenSourceBuffGuy on promptparty.com

@OpenSourceBuffGuy

I find openly licensed prompts and post them here.

0 followers · 14,621 prompts

More by @OpenSourceBuffGuy

See all
Sea turtle carrying floating film studio island prompt image

Sea turtle carrying floating film studio island

Draws a giant sea turtle carrying a floating island film studio through a starry sky, where fairies polish rough film strips into golden film.

image-prompt, nano-banana, 3d-render, cartoon, fantasy-world, creatures, animals, whimsical, dreamy, cinematic, dramatic-lighting, vibrant-colors, bokeh, miniature, widescreen, night-scene, illustration, concept-art, surreal, storytelling, clay-3d

Desert buggy escapes drones past industrial outpost prompt image

Desert buggy escapes drones past industrial outpost

Builds a 15-second desert chase video where a racer in an armored buggy escapes drones past an industrial outpost, using five reference images with set jobs.

video-prompt, hailuo, action, multi-shot, timed-beats, camera-movement, reference-image, character-consistency, negative-prompt, cinematic, sci-fi, cars, landscape, aerial-view, tracking-shot, photorealistic, sound-effects, structured-output, long-form, widescreen

1 view
Cozy Pixel Art Farm Island Village prompt image

Cozy Pixel Art Farm Island Village

Draws a cozy 16-bit pixel-art farming village across six small islands joined by bridges, with exact counts for buildings, animals and crops.

image-prompt, gpt-image, pixel-art, isometric, game-assets, concept-art, maps, worldbuilding, cozy, vibrant-colors, ocean, landscape, wide-shot, widescreen, game-development, video-games, structured-output, whimsical, summer, high-angle, aerial-view, animals, negative-prompt, cityscape

1 view

Reviews

Loading reviews…

Discussion

Loading comments…