Skip to content

Commit

Permalink
chore: Updated docs
Browse files Browse the repository at this point in the history
  • Loading branch information
gabrielmjr authored Oct 27, 2024
1 parent b58d6a5 commit 94dc714
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# Terminal Local Chat
***This project is a terminal local chat between two devices where one is hosting (by turning on hotspot) and other is client (by connecting to the turned on hotspot)***.
***This project is a terminal local chat between two devices connected to the same Wi-Fi network (alternativelly you can use hotspot-Wi-Fi)***.

![Build state](https://github.com/gabrielmjr/terminal-local-chat/actions/workflows/maven.yml/badge.svg)

### How it works?
As the name suggests, it works locally between two devices (Later on this number will be increased), where one turns on [hotspot](https://en.wikipedia.org/wiki/Wi-Fi_hotspot#:~:text=A%20hotspot%20is%20a%20physical,to%20an%20Internet%20service%20provider.), we call this device as server, other turns on [WI-Fi](https://en.wikipedia.org/wiki/Wi-Fi) and connects to the hotspot, we call this device as client, both run the [jar file](https://docs.oracle.com/javase/8/docs/technotes/guides/jar/jarGuide.html), follow the instructions, after all, they can chat together locally using terminal.
As the name suggests, it works locally between two devices (Later on this number will be increased), connected to the same Wi-Fi, or one turns on [hotspot](https://en.wikipedia.org/wiki/Wi-Fi_hotspot#:~:text=A%20hotspot%20is%20a%20physical,to%20an%20Internet%20service%20provider.), other turns on [WI-Fi](https://en.wikipedia.org/wiki/Wi-Fi) and connects to the hotspot, both run the [jar file](https://docs.oracle.com/javase/8/docs/technotes/guides/jar/jarGuide.html), follow the instructions, after all, they can chat together locally using terminal.

To make they communicate themselves, I used server socket, where after one device connect to the other, both sides waits for the received message and print it from a background [Thread](https://www.w3schools.com/java/java_threads.asp) and while the background thread waits for the received message, the main thread is sending the message by using socket connections and [streams](https://www.javatpoint.com/java-8-stream) does this conversion from Strings to byte arrays and the reverse work.

Expand All @@ -14,8 +14,7 @@ The String before converted to bytes and be sent, it's serialized to [JSON](http
### Get started
To use of the terminal local chat, you must to:
1. Have two devices (and terminal in them).
2. In the server device, you must turn on hotspot.
3. In the client device, you must connect to the server's hotspot, using WI-FI.
2. Connect them to the same Wi-FI (or turn on hotspot in one device and connect to it from other device).
3. Have a [Java Envinronment](https://www.java.com/en/download/manual.jsp).
4. Download a [release](https://github.com/gabrielmjr/terminal-local-chat/releases) executable jar file (I recommend the latest). [Optionally you can clone the repository and compile it yourself]].
5. Run the jar file by using:
Expand All @@ -33,26 +32,26 @@ Just enter an username.
7. The console will show you:
```
Type 1 to be the server (Turn on hotspot).
Type 2 to be the client (Turn on wifi).
Type 1 to be the server.
Type 2 to be the client.
```

8. To the device where hotspot is on, enter 1 and the terminal will show you:
8. Enter 1 in one of the devices, then the console will show you:
```
>>> Enter the port to listen:
```
- Just choose the port (1024-65535) and wait the other device to connect.
The terminal will show you:
```
Serving in ip: [your hotspot ip], port: [choosen port]
Serving in ip: [local ip], port: [choosen port]
```
Use the hotspot ip and choosen port in the other device doing:
Use the local ip and choosen port in the other device doing:

9. In the device where the WI-FI is connected, enter 2 and the terminal will show you:
9. In the other device, enter 2 and the console will show you:
```
>>> Enter the ip address:
```
- Enter the ip shown in the device where hotspot is on, then the terminal will show you;
- Enter the ip shown in the other device device, then the terminal will show you;
```
Enter the listened port:
```
Expand Down

0 comments on commit 94dc714

Please sign in to comment.