Skip to content

Latest commit

 

History

History
279 lines (223 loc) · 6.95 KB

File metadata and controls

279 lines (223 loc) · 6.95 KB

⚡ Quick Start Guide

Get the Online Quiz System running in 5 minutes!

🚀 Fast Setup (3 Steps)

Step 1: Build the Project

cd "e:\MCQ spring"
mvn clean install

⏱️ Wait for "BUILD SUCCESS"

Step 2: Start the Server

# Option A: Using batch file (Windows)
run-server.bat

# Option B: Using Maven
mvn spring-boot:run

✅ Wait for "Quiz Server Started on Port: 5000"

Step 3: Run Clients (Open 2+ terminals)

# Option A: Using batch file (Windows)
run-client.bat

# Option B: Using Java
java -cp target\online-quiz-system-1.0.0.jar com.quiz.client.QuizClient

✅ Enter player name when prompted

🎮 Play the Quiz

  1. Server: Automatically starts when 2+ players join
  2. Clients: Answer questions (1-4)
  3. Results: View scores in console + UDP broadcast

🌐 Web Dashboard

Open browser: http://localhost:8080

  • View server status
  • Monitor active players
  • See live leaderboard
  • Refresh automatically every 5 seconds

📁 Project Structure (Quick Reference)

MCQ spring/
├── pom.xml                          # Maven config
├── run-server.bat                   # Start server (Windows)
├── run-client.bat                   # Start client (Windows)
├── README.md                        # Full documentation
├── SETUP_GUIDE.md                   # Detailed setup
├── NETWORK_CONCEPTS.md              # Concept explanations
└── src/main/
    ├── java/com/quiz/
    │   ├── QuizApplication.java     # Main Spring Boot app
    │   ├── model/                   # Data models
    │   ├── service/                 # Business logic
    │   ├── server/                  # Server components
    │   ├── client/                  # Client application
    │   └── controller/              # REST APIs
    └── resources/
        ├── application.properties   # Configuration
        └── static/                  # Web UI files

🎯 Network Concepts Implemented

# Concept File Description
1 TCP Socket QuizServer.java Reliable client-server connection
2 Multithreading ClientHandler.java Concurrent client handling
3 Synchronization QuizService.java Thread-safe score management
4 UDP Broadcasting UDPBroadcaster.java Final results broadcast
5 Client-Server QuizClient.java Bidirectional communication

🔧 Configuration (Quick Edit)

File: src/main/resources/application.properties

server.port=8080              # Web server port
quiz.server.tcp.port=5000     # TCP socket port
quiz.server.udp.port=5001     # UDP broadcast port
quiz.server.max.clients=10    # Max concurrent clients

🐛 Common Issues & Fixes

❌ "Port already in use"

# Windows
netstat -ano | findstr :5000
taskkill /PID <process_id> /F

❌ "Connection refused"

  • Ensure server is running
  • Check firewall settings
  • Verify ports 5000, 5001, 8080 are open

❌ "Build failed"

mvn clean install -U

❌ "Java/Maven not found"

  • Install JDK 17+
  • Install Maven 3.6+
  • Add to PATH environment variable
  • Restart terminal

📊 Testing Checklist

  • Server starts successfully
  • Web UI loads (http://localhost:8080)
  • 2+ clients can connect
  • Questions display correctly
  • Answers are submitted
  • Scores update properly
  • Final results shown
  • UDP broadcast received

💡 Tips for Demo/Presentation

Preparation

  1. Build project beforehand
  2. Test with 3-5 clients
  3. Keep terminals organized
  4. Have web dashboard open

During Demo

  1. Show Architecture (README.md diagram)
  2. Start Server (show console output)
  3. Open Web Dashboard (show live monitoring)
  4. Connect Clients (show multiple terminals)
  5. Play Quiz (demonstrate flow)
  6. Show Results (TCP + UDP)
  7. Explain Code (highlight key concepts)

Key Points to Mention

  • ✅ TCP for reliable question/answer exchange
  • ✅ Multithreading handles 10+ concurrent clients
  • ✅ Synchronization prevents score corruption
  • ✅ UDP broadcasts results efficiently
  • ✅ Clean client-server architecture

🎓 For Each Team Member

Member 1: Server Developer (TCP Socket)

Your Code: QuizServer.java

ServerSocket serverSocket = new ServerSocket(tcpPort);
Socket clientSocket = serverSocket.accept();

Explain: How TCP establishes reliable connections

Member 2: Manager (Multithreading)

Your Code: ClientHandler.java

public class ClientHandler implements Runnable {
    @Override
    public void run() { ... }
}

Explain: How each client runs in separate thread

Member 3: Client Developer (Client-Server)

Your Code: QuizClient.java

Socket socket = new Socket(SERVER_HOST, SERVER_PORT);

Explain: How client communicates with server

Member 4: Score Manager (Synchronization)

Your Code: QuizService.java

public synchronized boolean addPlayer(...) { ... }
synchronized (scoreLock) { ... }

Explain: How synchronization prevents race conditions

Member 5: Broadcaster (UDP)

Your Code: UDPBroadcaster.java

DatagramSocket socket = new DatagramSocket();
socket.setBroadcast(true);
DatagramPacket packet = new DatagramPacket(...);
socket.send(packet);

Explain: How UDP broadcasts to all clients

📞 Quick Commands Reference

# Build
mvn clean install

# Run Server
mvn spring-boot:run
# OR
run-server.bat

# Run Client
java -cp target\online-quiz-system-1.0.0.jar com.quiz.client.QuizClient
# OR
run-client.bat

# Check Server Status
curl http://localhost:8080/api/quiz/info

# View Leaderboard
curl http://localhost:8080/api/quiz/leaderboard

# Find Process on Port
netstat -ano | findstr :5000

# Kill Process
taskkill /PID <process_id> /F

📚 Documentation Files

  • README.md - Complete project documentation
  • SETUP_GUIDE.md - Detailed installation guide
  • NETWORK_CONCEPTS.md - In-depth concept explanations
  • QUICK_START.md - This file (quick reference)

✅ Success Indicators

Your setup is working when you see:

Server Console:

===========================================
Quiz Server Started on Port: 5000
Waiting for clients to connect...
===========================================
Player joined: Alice (uuid-1234)
Player joined: Bob (uuid-5678)
Starting quiz with 2 players

Client Console:

Connected to Quiz Server!
Enter your name: Alice
Waiting for other players... (2 players connected)

Question 1 of 5
What is 2 + 2?
1. 3
2. 4
3. 5
4. 6
Your answer (1-4):

Web Dashboard:

  • Status: RUNNING ✅
  • TCP Port: 5000 ✅
  • UDP Port: 5001 ✅
  • Active Players: 2+ ✅

🎉 You're Ready!

Everything is set up and ready to run. Good luck with your project presentation!


Need more details? Check the other documentation files:

  • Full docs: README.md
  • Setup help: SETUP_GUIDE.md
  • Concepts: NETWORK_CONCEPTS.md