Generate Socket.IO server and client setup for real-time applications
Create Socket.IO application for:
Application Type: {{APP_TYPE}} (chat/game/collaboration)
Server Framework: {{FRAMEWORK}}
Features: {{FEATURES}}
Generate complete Socket.IO structure:
1. **Server Setup:**
- Socket.IO initialization
- CORS configuration
- Authentication middleware
- Connection handling
- Disconnection cleanup
2. **Event Handlers:**
- Event registration
- Event validation
- Broadcast patterns
- Acknowledgments
- Error handling
3. **Rooms and Namespaces:**
- Namespace organization
- Room management
- Join/leave logic
- Room broadcasting
4. **Authentication:**
- Socket middleware
- JWT verification
- Session integration
- User identification
5. **Client Setup:**
- Connection management
- Reconnection handling
- Event listeners
- Emit patterns
6. **React Integration:**
- useSocket hook
- Context provider
- Event subscriptions
- Cleanup handling
7. **State Synchronization:**
- Initial state sync
- Delta updates
- Conflict resolution
- Optimistic updates
8. **Scaling:**
- Redis adapter
- Sticky sessions
- Horizontal scaling
- Load balancing
9. **Testing:**
- Socket.IO client mock
- Integration tests
- Event testing
Include presence system example.Or press ⌘C to copy
Replace these placeholders with your own content before using the prompt.
[{APP_TYPE][{FRAMEWORK][{FEATURES]