Design a Discord-like chat server that accepts multiple clients over raw TCP (e.g., test via PuTTY/telnet).
Functional requirements:
-
Clients connect over TCP and can send line-based messages.
-
Support slash commands:
-
/help
show available commands
-
/nick <name>
set/change nickname
-
/users
list users (at least in current room, or globally—state your choice)
-
/quit
disconnect
-
Chat rooms:
-
Create rooms, join rooms, and list rooms
-
Messages sent to a room are broadcast to all users currently in that room
-
Reconnection:
-
If a client disconnects and later reconnects (identify how), they should be able to rejoin their previous rooms
-
Message history:
-
When a user joins a room, show the last 10 messages from that room
-
Persistence:
-
Data must persist across server restarts (users/rooms/membership/messages as needed)
Non-functional requirements:
-
Keep scalability in mind (multiple concurrent clients; discuss how to scale beyond one process/host).
Explain your protocol, core data model, key components, and how you would handle concurrency, durability, and scaling.