A real-time client-server chat application. Supports a Qt GUI and React web clients. This project was created for a school assignment, and has since been polished and expanded.
sudo apt install cmake g++ qt6-base-dev nlohmann-json3-devNode 18+ is needed for the web client and gateway.
Qt is only required for the desktop GUI. To work on the server or web client without installing it, see Building without Qt.
cmake --preset dev
cmake --build --preset devBinaries land in bin/. The preset handles the Qt lookup, so no environment
variables or -D flags are needed.
The preset looks for the Qt online installer's default location,
~/Qt/6.10.1/gcc_64, and otherwise falls back to the system Qt from
qt6-base-dev. If yours is elsewhere, or is a different version, create
CMakeUserPresets.json in the repo root (it is gitignored, so it stays local):
{
"version": 3,
"configurePresets": [
{
"name": "local",
"inherits": "dev",
"cacheVariables": {
"CMAKE_PREFIX_PATH": "$env{HOME}/Qt/6.11.0/gcc_64"
}
}
]
}Then build with cmake --preset local and cmake --build --preset local.
cmake --preset dev -D BUILD_CLIENT_GUI=OFF
cmake --build --preset devThe server listens on port 5000. Start it first:
./bin/server 5000./bin/client 127.0.0.1 5000The gateway bridges the browser's WebSocket to the server's TCP socket. It takes the server host, the server port, and the port to serve WebSockets on:
cd gateway
npm install
node gateway.js 127.0.0.1 5000 8080Then, in another terminal, create client_site/.env with:
VITE_GATEWAY_URL=ws://localhost:8080
and start the dev server:
cd client_site
npm install
npm run devThe live server listens on port 5000.
./client cchat.fun 5000You can also connect from a local browser environment with:
VITE_GATEWAY_URL=ws://cchat.fun:8080