feat: better readme
This commit is contained in:
94
README.md
94
README.md
@@ -1,5 +1,24 @@
|
||||
# ClientServer
|
||||
|
||||
A Java-based ☕️↔️ UDP client-server chat 💬 system with automatic 🔄 text-to-emoji 😊 conversion using Mistral API.
|
||||
|
||||
## Features
|
||||
|
||||
### Available Commands
|
||||
|
||||
- `/list` : Display connected clients list
|
||||
- `/msg <nickname> <message>` : Send private message to specific client
|
||||
- `/help` : Display help with all available commands
|
||||
- `/disconnect` : Clean server disconnection
|
||||
- `<message>` : Broadcast message translated to emojis to all connected clients
|
||||
|
||||
### Technical Features
|
||||
|
||||
- UDP Communication
|
||||
- Multi-threading for client handling
|
||||
- Mistral API for text-to-emoji conversion
|
||||
- Disconnection handling
|
||||
|
||||
## Build
|
||||
|
||||
```bash
|
||||
@@ -11,33 +30,76 @@
|
||||
### Client
|
||||
|
||||
```bash
|
||||
./gradlew run --args='client'
|
||||
./gradlew runClient
|
||||
```
|
||||
|
||||
or
|
||||
|
||||
```bash
|
||||
./gradlew runServer
|
||||
```
|
||||
The client will ask for a pseudo, an IP (type `localhost` if server and clients are on the same machine), and a port (type `6666` by default).
|
||||
|
||||
### Server
|
||||
|
||||
```bash
|
||||
./gradlew run --args='server'
|
||||
```
|
||||
|
||||
or
|
||||
|
||||
```bash
|
||||
./gradlew runServer
|
||||
```
|
||||
|
||||
## Configuration
|
||||
|
||||
Create a `config.properties` file at project root (`ClientServer/app/config.properties`) with:
|
||||
|
||||
```properties
|
||||
mistral.api.key=your_api_key
|
||||
```
|
||||
|
||||
Replace `your_api_key` with your actual Mistral API key. Create one for free at https://console.mistral.ai/api-keys. If no API key is provided, the server will not be able to convert broadcasted messages to emojis and empty broadcasted messages will be sent.
|
||||
|
||||
## Documentation
|
||||
|
||||
### Sequence Diagram
|
||||
|
||||
```mermaid
|
||||
sequenceDiagram
|
||||
Note over Client, Serveur: DatagramSocket("localhost", 66666)
|
||||
Client->>+Serveur: DatagramPacket("Salve !", 7, "localhost", 6666)
|
||||
Note over Serveur, Client: DatagramSocket("localhost", 66666)
|
||||
Serveur->>+Client: DatagramPacket("Accusé de réception", 19, "localhost", 6666)
|
||||
participant MainServer
|
||||
|
||||
participant Alice
|
||||
Note over Alice: Creates DatagramSocket
|
||||
Alice->>+MainServer: Sends username "Alice"
|
||||
Note over MainServer: Creates new socket<br/>for AliceHandler
|
||||
create participant AliceHandler
|
||||
MainServer->>AliceHandler: Create new handler thread
|
||||
MainServer->>-Alice: PORT:{AlicePort}
|
||||
|
||||
participant Bob
|
||||
Bob->>+MainServer: Sends username "Bob"
|
||||
Note over MainServer: Creates new socket<br/>for BobHandler
|
||||
create participant BobHandler
|
||||
MainServer->>BobHandler: Create new handler thread
|
||||
MainServer->>-Bob: PORT:{BobPort}
|
||||
|
||||
rect rgb(200, 200, 255)
|
||||
Note over Alice,Bob: Chat loop
|
||||
Alice->>+AliceHandler: "Hi everyone!"
|
||||
Note over AliceHandler: Converts to emojis
|
||||
AliceHandler->>+BobHandler: Broadcast message
|
||||
BobHandler->>-Bob: "Alice: 👋👩👩🌍🎉"
|
||||
AliceHandler->>-Alice: Message sent
|
||||
|
||||
Bob->>+BobHandler: "Hello Alice, how are you?"
|
||||
Note over BobHandler: Converts to emojis
|
||||
BobHandler->>+AliceHandler: Broadcast message
|
||||
AliceHandler->>-Alice: "Bob: 👋🏻👩🏼🦰🐰🤔👩🏼🦰🐇💬👩🏼🦰🐰👍🏻😊👩🏼🦰🐇👋🏻"
|
||||
BobHandler->>-Bob: Message sent
|
||||
end
|
||||
|
||||
Alice->>+AliceHandler: /disconnect
|
||||
Note over AliceHandler: Removes Alice<br/>from map
|
||||
AliceHandler->>-Alice: Disconnection confirmation
|
||||
AliceHandler->>MainServer: Thread terminated
|
||||
MainServer-->>AliceHandler: destroy
|
||||
|
||||
Bob->>+BobHandler: /disconnect
|
||||
Note over BobHandler: Removes Bob<br/>from map
|
||||
BobHandler->>-Bob: Disconnection confirmation
|
||||
BobHandler->>MainServer: Thread terminated
|
||||
MainServer-->>BobHandler: destroy
|
||||
|
||||
Note over Alice,Bob: Close sockets
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user