---
tags : P&O-CW-2022-2023
creator: Joep Demollin
---
# README team-01-chatter
We have made a chatprogram which is runnable inside a terminal enivorment on both Linux and Windows.
## Step 0: Setting up your pc
To run the program, you will need to make sure you have the correct packages.
To do this open your terminal, navigate to the projectfolder and run npm ci
```
./team-01-chatter $ npm ci
```
## Step 1: Running the program
The program always consits of atleast the a server running to which clients can connect.
Without a server, the user won't see anything happen client-side.
1. Thus the first thing to do is start the server (without debug messages):
```
npm run server
```
- For receiving debug messages use :
```
npm run runDevServer
```
2. Once this is done we can start one or more clients:
```
npm run client
```
- A URL can be specified when using localtunnel, for example :
```
npm run client ws://gold-cows-create-23-110-123-235.loca.lt
```
## Step 2: Using the program
Below you will find all information on how to navigate through the program once it has been started.
:::warning
The program will work fine on both Linux and Windows, but the Windows terminal won't allow mouse usage. On Windows you can navigate by using tab and select by pressing enter.
:::
### Logging in

On starting, this screen should be shown to you, leaving you with two choices: to log in with an existing account, or create a new one.
#### Existing account
If you already have an account set up, entering the email and password of said account and pressing confirm will log you in.
This will bring you to the 'limbo'-state, you can continue [here](#Joining-a-channel).
#### Create new account
To create a new account, press new account. You should now be seeing this screen:

Here you are asked to input:
- An emailadress: this has to be unique
- A username: this is entirely open to your choice
- A password: keep it safe
- Repeat: your password repeated
If all this is entered correctly, you can press cofirm and you will [continue](#Joining-a-channel) to the 'limbo'-state.
### Joining a channel

##### Welcome to what we like to call the **'limbo'-state**. This is the place you will be at if **you are logged in, but are not currently in a chatroom**.
- In the top box you will see all channels you can join.
- In the bottom box you can type commands, press enter to confirm. If what you type is not recognized as a command, nothing will be done.
- The middle red text will give you information. This can be possible commands and what parameters they need, or a message telling you what went wrong.
- At the bottom you see your username and userId.
:::info
For a full overview of the commands and which are their parameters, look [here](#User-commands)
:::
##### Let's say you want join a room, what do you do?
1. You choose the room to join among the available rooms. We'll join "main"
2. See what it's channelid is (It's shown with the name)
3. Enter the command to join:
```
\join-room #GZovy
```
4. Press enter, you will now join the chatroom
### Chatting

You have now joined a chatroom. In this room you can see messages by everyone in this room!
Unfortunately at the time of making this I was the only one in this room.
Any messages you send will be shown to everyone in the room. You can see the time of sending the message aswell as which user send it to you.
:::info
You **will not see** messages sent before the moment you joined the room. This is a design choice we made to **guarantee user privacy**.
Quite a lot is in place to save the message history per channel, but without good encryption, this would allow the server to keep track of all messages anyone ever sent.
:::
:::info
This picture is incomplete. On the right of your screen you should see a list of active users in the channel.
:::
In this channel, the same [commands](#User-commands) as in the limbo-state can be used.
### Keystrokes
A big part of the program is the **registering of the keystrokes**. This happens at every keypress.
To activate sharing keystroke information with a user, the command
```
\share-keystrokes {userid}
```
is used. This means the user who's id you have given will receive your timings and can thus create a profile to identify you by your keystrokes.
### User commands
We have selected commands as the way users will interact with their client.
To distinguish a command from a regular message all commands will start with a **\ backslash** and will use **lowercase-kebab-case**.
This is an overview of the commands so far:
- \change-name {new nickname} {password}
- \change-password {new password} {old password}
- \join-room {room id}
- \leave-room
- \create-room {room name}
- \delete-room {room id}
- \delete-profile {password}
- \logout
- \share-keystrokes {userid}
- \disable-sharekeystrokes {userid}
:::warning
If a command doesn't have a parameter given, it takes none.
:::
## Step 3: Closing the program
When you are done chatting, you have 2 options. You can:
- kill the terminal, ending the program, or
- use the **/logout** command. This ends the websocket and logs you out. **But cruciually starts a new websocket.**
Either way the websocket (by which a user is identified) is ended. If you use the command the program isn't ended though. This way another user can easily log in without restarting.