Skip to main content

WebSocket Presence Management

SDD Classification: L3-Technical Authority: Engineering Team Review Cycle: Quarterly
Presence management enables awareness of other users in real-time collaboration, including cursor positions, selections, typing indicators, and activity status.

Presence Overview


Presence Data Structure

User Presence Object


Presence Events

User Joined

When a user connects to the document:

User Left

When a user disconnects:

Cursor Update

Real-time cursor position:

Selection Update

When user selects text:

Typing Indicator

Shows when user is actively typing:

Presence Manager Implementation


Rendering Remote Cursors

Cursor Component

CSS Styles


User List Component

React Implementation


Presence Throttling

Update Frequency Limits

Server-Side Throttling

The server may throttle presence updates:

Best Practices

Do

  1. Throttle updates - Prevent network flooding
  2. Use distinct colors - Make users easily identifiable
  3. Show cursor labels on hover - Don’t clutter the UI
  4. Handle disconnect gracefully - Remove stale cursors
  5. Animate cursor movements - Smooth visual updates

Don’t

  1. Don’t send every keystroke - Batch typing indicators
  2. Don’t track mouse position - Only cursor/selection
  3. Don’t persist presence data - It’s ephemeral
  4. Don’t block on presence updates - Handle asynchronously
  5. Don’t ignore idle users - Update their status appropriately


Document Status: Complete Version: 2.0