Skip to content

Its a Chatroom with Node.js.You can use some tool like Ngork to let everyone chat on it.

License

Notifications You must be signed in to change notification settings

yiyuntao2025/node-chatroom

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Node.js Real-time Chat Application

A modern, real-time chat application built with Node.js, Express, and Socket.IO. Features text messaging, image sharing, file transfers, and real-time user presence.

Version Node.js Socket.IO License

✨ Features

  • Real-time Messaging: Instant text communication with other users
  • Media Sharing: Send and receive images directly in chat
  • File Transfers: Share files with icon-based visual indicators
  • User Presence: See who's online in real-time
  • Responsive Design: Works on desktop and mobile devices
  • File Security: 10MB file size limit with type validation
  • Modern UI: Gradient design with smooth animations

📁 Project Structure

chat-app/
├── server.js                 # Main server file
└── public/
    ├── index.html            # Frontend interface
    └── favicon.ico           # Website icon

🚀 Quick Start

Prerequisites

  • Node.js (v14 or higher)
  • npm or yarn

Installation & Running

  1. Clone or download the project files

    Create a folder with server.js and public/ directory containing index.html and favicon.ico

  2. Install dependencies

    Open terminal in project directory and run: npm init -y npm install express socket.io

  3. Start the server

    node server.js

  4. Access the application

    • Open browser and navigate to: http://localhost:33333
    • Or use your local IP address shown in console

🔧 Usage Guide

Joining the Chat

  1. Enter a username in the input field
  2. Press Enter or click outside the field
  3. Read the chat rules displayed upon joining

Sending Messages

  • Text: Type in the message box and press Enter/Send
  • Images: Click the image button and select an image file
  • Files: Click the file button and select any file type

Viewing Content

  • Images: Click to view in full-screen modal
  • Files: Click to see file details and download options

Online Users

  • Right sidebar displays all connected users
  • User count updates in real-time

⚙️ Technical Details

Server Configuration

  • Port: 33333 (configurable in server.js)
  • Host: 0.0.0.0 (accessible from network)
  • CORS: Enabled for all origins
  • File Limit: 10MB maximum per file

File Type Icons

The application displays appropriate icons for different file types:

  • 📄 Documents (PDF, TXT, DOC)
  • 📊 Spreadsheets (XLS, CSV)
  • 🖼️ Images (JPG, PNG, GIF)
  • 🎵 Audio (MP3, WAV)
  • 🎬 Video (MP4, AVI)
  • 📦 Archives (ZIP, RAR)
  • ⚙️ Executables (EXE, MSI)

📡 Network Access

The server automatically detects and displays:

  • Localhost URL: http://localhost:33333
  • Local IP URL: http://[YOUR-IP]:33333
  • Network access for other devices on the same network

🔒 Security Features

  1. Input Validation: Basic client-side file size validation
  2. Content Sanitization: HTML content handling
  3. Connection Management: Proper user join/leave tracking
  4. File Restrictions: 10MB size limit to prevent abuse

🐛 Troubleshooting

Common Issues

Port already in use: Change PORT variable in server.js line 144

Socket connection failed: Ensure firewall allows port 33333

Files not sending: Check file size (must be ≤10MB)

Users not appearing: Refresh browser or check console for errors

Development Mode

For debugging, add this to server.js after line 10: console.log('Debug: New connection from', socket.handshake.address);

📱 Browser Compatibility

  • Chrome 60+ ✓
  • Firefox 55+ ✓
  • Safari 11+ ✓
  • Edge 79+ ✓
  • Mobile browsers ✓

🛠️ Development

Extending Features

To add new file type icons, modify the fileIcons object in server.js (lines 22-30):

const fileIcons = { // Add new mappings here 'py': '🐍', // Python files 'js': '📜', // JavaScript files 'html': '🌐', // HTML files // ... existing mappings };

Customizing Port

Change the PORT constant in server.js line 144: const PORT = 33333; // Change to desired port

📄 License

This project is licensed under the MIT License - see the LICENSE file for details.

🙏 Acknowledgments

  • Built with Express.js
  • Real-time functionality powered by Socket.IO
  • Icons from Unicode emoji set
  • Gradient designs inspired by modern web trends

⚠️ Important Notes

  1. This is a demonstration application - not suitable for production without additional security measures
  2. All files are transferred as Base64 - consider chunking for large files
  3. No persistent storage - messages are lost on server restart
  4. No authentication - anyone can join with any username
  5. Monitor server resources when sharing large files

Enjoy chatting! For questions or issues, please check the console for error messages and ensure all dependencies are properly installed.

About

Its a Chatroom with Node.js.You can use some tool like Ngork to let everyone chat on it.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published