@@ -14,7 +14,12 @@ Network Chat is a Java 21 chat application over TCP sockets with:
1414- a resilient server with user handshake and broadcast.
1515- a console client.
1616- a bot client with date/time commands.
17- - a Swing GUI client using MVC style structure.
17+ - a Swing GUI client with an embedded connection panel, retry/cancel flow, saved last settings,
18+ local message timeline, rooms, private messages, and MVC style structure.
19+ - optional file-backed message history with room replay after server restart.
20+ - optional TLS mode, token-based accounts with ` USER ` /` ADMIN ` roles, and the admin ` /health `
21+ command.
22+ - a Windows release zip with launch scripts, checksums, and provenance metadata.
1823- reproducible Gradle build, tests, CI, and quality gates.
1924
2025![ Swing GUI client] ( docs/images/gui-client.svg )
@@ -39,14 +44,70 @@ Server and clients can also be run directly with Java by building jars from Grad
3944The default server port is ` 1500 ` . Programmatic server startup can use ` ChatServerConfig ` to set the
4045port, maximum client count, handshake timeout, and post-handshake read timeout.
4146
47+ To enable file-backed history:
48+
49+ ``` bash
50+ ./gradlew runServer --args=" --port 1500 --history build/chat-history.jsonl"
51+ ```
52+
53+ To enable accounts, first generate rows for ` accounts.csv ` :
54+
55+ ``` bash
56+ ./gradlew createAccount --args=" alice USER secret" >> build/accounts.csv
57+ ./gradlew createAccount --args=" admin ADMIN admin-secret" >> build/accounts.csv
58+ ./gradlew runServer --args=" --port 1500 --accounts build/accounts.csv"
59+ ```
60+
61+ Clients send the token through the GUI ` Token ` field or the ` NETWORK_CHAT_TOKEN ` environment
62+ variable. Admin users can send ` /health ` and receive a private server status response.
63+
64+ To enable TLS, create a Java keystore for the server:
65+
66+ ``` bash
67+ keytool -genkeypair -alias network-chat -keyalg RSA -keysize 3072 -validity 365 \
68+ -keystore build/network-chat.p12 -storetype PKCS12 -storepass changeit
69+ ./gradlew runServer --args=" --port 1500 --tls-keystore build/network-chat.p12 --tls-password changeit"
70+ ```
71+
72+ Clients enable TLS through environment variables:
73+
74+ ``` powershell
75+ $env:NETWORK_CHAT_TLS="true"
76+ $env:NETWORK_CHAT_TRUSTSTORE="build/network-chat.p12"
77+ $env:NETWORK_CHAT_TRUSTSTORE_PASSWORD="changeit"
78+ ./gradlew runGuiClient
79+ ```
80+
81+ To build a no-Gradle release package for end users:
82+
83+ ``` bash
84+ ./gradlew releaseBundle
85+ ```
86+
87+ Artifacts are written to ` build/release ` : the Windows zip, ` checksums.txt ` , and ` provenance.json ` .
88+
4289## Architecture and protocol
4390
4491The compact architecture contract is documented in [ docs/architecture.md] ( docs/architecture.md ) .
4592
4693- ` ChatServer ` accepts TCP connections and handles clients in a bounded executor.
4794- ` ChatConnection ` reads and writes one-line UTF-8 JSON frames.
4895- ` ChatProtocol ` serializes ` ChatMessage ` .
96+ - ` ChatMessage ` carries ` protocolVersion ` ; unversioned clients receive an explicit ` ERROR ` .
4997- For ` TEXT ` messages, ` data ` contains only raw text and ` sender ` contains the author.
98+ - ` TEXT ` messages are broadcast to every client, including the sender, so users see their own sent
99+ messages in the timeline.
100+ - ` ROOM_TEXT ` is delivered only to room members; ` PRIVATE_TEXT ` is delivered only to the sender and
101+ recipient.
102+ - The GUI keeps a bounded local timeline for the current session, renders ` USER_ADDED ` /` USER_REMOVED `
103+ as service events, uses ` messageId ` for deduplication, and supports search by text, sender,
104+ date/timestamp, room, recipient plus JSON/CSV export.
105+ - When history is enabled, the server stores ` ROOM_TEXT ` /` PRIVATE_TEXT ` frames as JSONL, bounds the
106+ history size, migrates legacy unversioned ` TEXT ` records, and replays recent room messages on
107+ join.
108+ - When accounts are enabled, the server accepts only ` USER_NAME ` frames with a valid token; roles are
109+ used for admin-only commands.
110+ - TLS is enabled through server configuration and client environment variables.
50111- Console and Swing clients format display text such as ` alice: hello ` .
51112- The bot client reads date/time commands from ` data ` and uses the author from ` sender ` .
52113
@@ -124,8 +185,16 @@ This repository is organized for maintainability:
124185- GUI does not render in CI: UI smoke tests skip automatically in headless environments.
125186- Client disconnects immediately: check username uniqueness and nickname length (` 3..64 ` , letters, digits, ` _ ` , ` - ` ).
126187- Client receives ` Server is busy ` : the configured ` ChatServerConfig.maxClients ` limit has been reached.
188+ - GUI shows ` No connection ` : check host/port and use the reconnect button; the last entered settings
189+ are stored locally.
190+ - A corrupt line in the history file is skipped during startup; valid history still loads.
191+ - ` Authentication failed ` : check the user row in ` accounts.csv ` and the GUI token field or
192+ ` NETWORK_CHAT_TOKEN ` .
193+ - TLS trust errors: set ` NETWORK_CHAT_TRUSTSTORE ` on the client or use a certificate trusted by the
194+ JVM.
127195
128196## Roadmap
129197
130- - v1.1.x: stabilize protocol/server lifecycle, expand negative tests, and improve documentation.
131- - Later: rooms, message history, TLS, and persistent accounts as separate product-focused phases.
198+ - v1.6.x: TLS, token accounts, release packaging, and security hardening are implemented in the
199+ current line.
200+ - Later: persistent user profiles and richer administration as separate product-focused phases.
0 commit comments