Real-time Updates
Cocobase provides real-time features through the db.realtime namespace. All connections use automatic reconnection with exponential backoff built in.Collection Watcher
Watch a collection for live document changes.Basic Usage
Watch with Filters
Project Broadcast
Send and receive messages across all connected clients.Room Chat
Create or join rooms for isolated real-time communication.List Rooms
Game Client
TheGameClient supports WebSocket-based game rooms. Use db.realtime.game() to connect:
Auto-Reconnection
All real-time connections automatically reconnect if dropped, using exponential backoff from 1 second up to 30 seconds maximum. No configuration needed.CollectionWatcher API Reference
ProjectBroadcast API Reference
RoomChat API Reference
Best Practices
- Always set up event handlers before calling connect()
- Always call disconnect() or leave() when done
- Use filters in CollectionWatcher to reduce events
- Use RoomChat for isolated group communication
- Use ProjectBroadcast for project-wide announcements
