AI generated prompt for WebSocket Real-time Chat Server
**Context**: Design a real-time chat server using WebSockets, enabling multiple clients to communicate with each other simultaneously. The server should handle connections, disconnections, and message broadcasting efficiently. The system should be scalable, secure, and support features like user authentication and message history. **Detailed Instructions**: 1. Develop a WebSocket server using a programming language of your choice (e.g., JavaScript with Node.js, Python with asyncio). 2. Implement user authentication using a library or framework (e.g., Passport.js for Node.js, Flask-Login for Python). 3. Design a data structure to store user information, including username, connection status, and message history. 4. Handle WebSocket connections and disconnections, updating user status and notifying connected clients. 5. Broadcast incoming messages to all connected clients, including the sender. 6. Implement a mechanism to store and retrieve message history for each user. 7. Ensure the server can handle a large number of concurrent connections and scale horizontally. 8. Implement security measures to prevent common WebSocket attacks (e.g., authentication, authorization, input validation). 9. Develop a client-side application (e.g., using JavaScript and the WebSocket API) to connect to the server and demonstrate real-time chat functionality. **Output Format**: Provide a detailed report including: - Server architecture and design decisions - Code snippets for key components (e.g., authentication, connection handling, message broadcasting) - Security considerations and measures implemented - Client-side application code and usage examples - Scalability and performance optimization strategies **Examples**: - A simple chat application with user authentication, where users can send and receive messages in real-time. - A collaborative editing tool, where multiple users can edit a document simultaneously, with real-time updates reflected on all connected clients. - A live updates feature for a web application, where users receive real-time notifications and updates on changes to the system.
This coding prompt is designed to help you get better results from AI assistants like ChatGPT, Claude, and Gemini. Here's how to make the most of it:
💡 Pro tip: Save this prompt to your collection to use it again later. Well-crafted prompts can save hours of back-and-forth with AI.
Adjust the prompt to match your specific industry, audience, or use case. Adding relevant context improves output quality.
Specify your desired output length (e.g., "in 200 words" or "in 3 bullet points") to get more targeted responses.
Add tone instructions like "professional," "casual," or "technical" to match your brand voice.
Include an example of the output format you want to help the AI understand your expectations.
This prompt has been tested and optimized for all major AI models. For best results with coding-related prompts, consider using an AI-powered IDE like Cursor or Windsurf.
Learn more about using prompts effectively with our comprehensive guides:
0 people found this prompt helpful
Based on 0 reviews
Be the first to share your experience with this prompt!
This prompt was reviewed and verified to work with current AI models.
Tested with ChatGPT, Claude & Gemini. Reviewed by community users.
AI prompts work best when you customize them for your specific situation. Follow these steps to get the most out of WebSocket Real-time Chat Server.