Presentation Sessions
Sessions enable real-time synchronization between presenters and audience members during live presentations.
Overview
Section titled “Overview”When you present a deck, a session is created to coordinate state across all connected clients. The session tracks which slide is active, handles follow codes, and broadcasts updates via Server-Sent Events (SSE).
How Sessions Work
Section titled “How Sessions Work”Session Lifecycle
Section titled “Session Lifecycle”- Create - Presenter starts presenting, session created
- Active - Audience joins, state synchronized
- Update - Presenter navigates, state broadcast
- Expire - No activity for 30 minutes, session cleaned up
Session Data
Section titled “Session Data”Each session stores:
{ sessionId: 'abc123', presentationId: 'pres456', state: { slideId: 'slide789', slideIndex: 3, slideType: 'content-slide', stepIdx: 0, stepParagraphs: false, updatedAt: 1705312200000 }, controlEnabled: false, followCodes: { nl: 'ABCD', en: 'EFGH' }, followCodesCreatedAt: 1705312200000, createdAt: 1705312200000, lastActivityAt: 1705312200000, clients: Set(), heartbeatTimers: Map()}Creating Sessions
Section titled “Creating Sessions”API Endpoint
Section titled “API Endpoint”POST /api/present/sessionContent-Type: application/json
{ "presentationId": "abc123"}Response
Section titled “Response”{ "sessionId": "xyz789", "joinPath": "/notes/xyz789", "followCodes": { "nl": "ABCD", "en": "EFGH" }}Session Reuse
Section titled “Session Reuse”If an active session exists for the presentation, it’s reused:
- Same session ID returned
- Follow codes refreshed if expired
- Activity timestamp updated
Session State
Section titled “Session State”State Properties
Section titled “State Properties”| Property | Description |
|---|---|
slideId | Current slide’s unique ID |
slideIndex | 0-based slide position |
slideType | Type of current slide |
stepIdx | Build step within slide |
stepParagraphs | Paragraph-level stepping enabled |
updatedAt | Last state change timestamp |
Updating State
Section titled “Updating State”When presenter navigates:
PATCH /api/present/session/:sessionId/stateContent-Type: application/json
{ "slideId": "slide789", "slideIndex": 5, "stepIdx": 2}State is broadcast to all connected clients via SSE.
Follow Codes
Section titled “Follow Codes”Purpose
Section titled “Purpose”Short, easy-to-share codes for audience to join.
Generation
Section titled “Generation”https://your-instance.com/goCode: ABCD- 4 uppercase letters
- One code per language
- Valid for 24 hours
Resolution
Section titled “Resolution”When audience enters a code:
- Code looked up in database
- Target URL returned
- Viewer redirected to follow view
- SSE connection established
Refresh
Section titled “Refresh”Codes are automatically refreshed:
- When they expire (24 hours)
- Session must still be active
- Presenter sees updated codes
SSE Connection
Section titled “SSE Connection”Connecting
Section titled “Connecting”Clients connect to receive updates:
const eventSource = new EventSource( '/api/present/session/ABC123/events');Initial State
Section titled “Initial State”On connection, clients receive:
- Current state snapshot
- Control enabled status
Event Types
Section titled “Event Types”| Event | Description |
|---|---|
state | Slide navigation |
controlEnabled | Audience control toggle |
deckUpdated | Presentation content changed |
interactionState | Poll/Q&A updates |
branch | Navigate to branched slide |
See Real-Time Updates for details.
Audience Control
Section titled “Audience Control”Toggle Control
Section titled “Toggle Control”Allow audience to self-navigate:
PATCH /api/present/session/:sessionId/controlContent-Type: application/json
{ "enabled": true}Control State
Section titled “Control State”- Disabled (default) - Audience locked to presenter’s slide
- Enabled - Audience can navigate freely
Broadcast
Section titled “Broadcast”Control state changes are broadcast to all clients.
Session Expiry
Section titled “Session Expiry”TTL (Time to Live)
Section titled “TTL (Time to Live)”Sessions expire after 30 minutes of inactivity.
Activity Tracking
Section titled “Activity Tracking”These actions reset the timer:
- State updates
- Client connections
- Control toggles
- Any API calls to session
Cleanup
Section titled “Cleanup”Expired sessions are:
- Removed from memory
- Cleaned from disk storage
- Follow codes invalidated
Manual Close
Section titled “Manual Close”Sessions can be explicitly closed:
DELETE /api/present/session/:sessionIdPersistence
Section titled “Persistence”Memory Storage
Section titled “Memory Storage”Active sessions are stored in memory for performance.
Disk Persistence
Section titled “Disk Persistence”Sessions are periodically saved to disk:
- On state changes (debounced)
- On graceful shutdown
- Loaded on server restart
Storage Location
Section titled “Storage Location”./server/data/present-sessions/Multiple Presenters
Section titled “Multiple Presenters”Session Sharing
Section titled “Session Sharing”Multiple users can present the same deck:
- Same session is reused
- State updates from any presenter
- All audience members see same state
Conflict Resolution
Section titled “Conflict Resolution”Last write wins - the most recent navigation is broadcast.
Heartbeats
Section titled “Heartbeats”Purpose
Section titled “Purpose”Keep SSE connections alive through proxies.
Interval
Section titled “Interval”Every 30 seconds:
: heartbeatClient Tracking
Section titled “Client Tracking”Each client has its own heartbeat timer:
- Created on connection
- Cleared on disconnect
- Used to detect stale connections
Scalability
Section titled “Scalability”Single Server
Section titled “Single Server”Default: sessions stored in memory, persisted to disk.
Horizontal Scaling
Section titled “Horizontal Scaling”For multiple servers:
- Use Redis for session storage
- Use Redis pub/sub for broadcasts
- Sticky sessions or distributed coordination
API Reference
Section titled “API Reference”Create Session
Section titled “Create Session”POST /api/present/sessionGet Session
Section titled “Get Session”GET /api/present/session/:sessionIdUpdate State
Section titled “Update State”PATCH /api/present/session/:sessionId/stateToggle Control
Section titled “Toggle Control”PATCH /api/present/session/:sessionId/controlClose Session
Section titled “Close Session”DELETE /api/present/session/:sessionIdSSE Events
Section titled “SSE Events”GET /api/present/session/:sessionId/eventsTroubleshooting
Section titled “Troubleshooting”Session Not Found
Section titled “Session Not Found”- Session may have expired
- Check sessionId is correct
- Verify session was created
Follow Code Not Working
Section titled “Follow Code Not Working”- Code may have expired (24 hours)
- Check code was typed correctly
- Verify session is still active
State Not Syncing
Section titled “State Not Syncing”- Check SSE connection is open
- Verify no network issues
- Look for errors in browser console
High Memory Usage
Section titled “High Memory Usage”- Many concurrent sessions
- Large numbers of connected clients
- Consider horizontal scaling