# v0.8.0 — DataChannel & Mesh Multi-party (2025-12-18)

> **Type**: `feat` | **Impact**: High

## Summary

Major feature release introducing peer-to-peer text chat, multi-party Mesh architecture, and security enhancements. This version transforms the project from a simple 1-on-1 demo to a full-featured multi-user communication platform.

---

## ✨ New Features

### 💬 DataChannel Chat
- **Peer-to-peer messaging** — No server relay for text messages
- **Send button & Enter key** — Intuitive message sending
- **System notifications** — Connection status updates in chat
- **Per-peer channels** — Individual DataChannels for each connection

### 👥 Multi-party Mesh Architecture
- **Room member list** — Real-time participant display
- **Dynamic PeerConnection management** — Automatic connection handling
- **Video grid layout** — Responsive layout for multiple remote streams
- **Up to 50 participants** — Per-room limit for performance

### 📺 Enhanced Media Features
- **Screen sharing** — Display capture with automatic video replacement
- **Local recording** — MediaRecorder integration with WebM export
- **Multi-party adaptations** — All features work with multiple peers

### 🔒 Security Enhancements
- **Origin validation** — WebSocket origin whitelist via `WS_ALLOWED_ORIGINS`
- **Identity verification** — Server-validated client IDs
- **Heartbeat mechanism** — `ping/pong` keepalive for connection health

---

## 🔧 Implementation Details

### Frontend Architecture
- **Unified state machine** — Predictable connection lifecycle
- **Multi-PeerConnection support** — `Map<string, Peer>` for managing peers
- **Perfect negotiation** — Collision-free offer/answer handling

### Backend Improvements
- **Connection cleanup sequence** — Prevents panic on rapid re-join
- **Origin parsing** — Flexible CORS-like origin validation

---

## 📁 Files Changed

```
internal/signal/hub.go        ← Origin validation, heartbeat
cmd/server/main.go            ← WS_ALLOWED_ORIGINS parsing
web/app.js                    ← Major restructure for Mesh
web/index.html                ← Chat UI, member list
docs/signaling.md             ← Updated protocol docs
README.md                     ← Updated feature list
```

---

## 🔌 Configuration

New environment variable:

```bash
# WebSocket origin validation
WS_ALLOWED_ORIGINS=localhost,yourdomain.com

# Use '*' to allow all origins (development only)
WS_ALLOWED_ORIGINS=*
```

---

## 🎯 Migration Guide

### For Existing Users
1. Update environment variables to include `WS_ALLOWED_ORIGINS`
2. No code changes required
3. Existing 1-on-1 calls continue to work

### For New Features
1. Join a room with multiple participants
2. Click member IDs to initiate calls
3. Use chat box for text messaging
4. Try screen share and recording

---

## 🐛 Known Limitations

- **Mesh topology** — Each participant relays media to all others (N-1 connections)
- **Browser performance** — Large rooms (20+) may strain client devices
- **No server-side media** — Pure P2P, no recording or processing on server

---

## 🔮 Future Work

- SFU architecture for large-scale calls (100+)
- Selective forwarding for bandwidth optimization
- Server-side recording capabilities

---

[← Back to Changelog Index](README.md)
