---
# System prepended metadata

title: Demo instructions

---

# Demo instructions
To run our chat application on your own computer, follow the steps below.

## Start the server
To start the chatserver, open your terminal and run this command:
```
npx ts-node-esm src/chat-server/chat-server-script.ts
```
Optionally, you can add `DEBUG=*` in front of this command to see the inner workings of the chatserver when clients interact with it.

## Start the client(s)

Clients can connect to the chatserver with the following command:
```
npx ts-node-esm src/chat-client/chat-client.ts
```
### Logging in
To be able to send messages to other users, you will need to create an account and log in to the chatserver. As shown in the terminal, you will be in overview mode when you are not yet logged in. Press enter to go into message mode. A `:` will appear. You can now type to create an account with the `/login [userId] [password]` command. 
:::warning 
**NOTE:** Only user ID's that start with a 'r', followed by seven digits will be accepted. You are free to choose a password. For example:
`/login r0796128 pass`✅
`/login steven pass`❌
:::

Once you have created your account, you will receive a confirmation message from the server. Since you just made a new account, you will be put in the channel `general`, which is the standard channel that gets initialized when the server starts. A notification will tell you who else is **online** in the channel you just joined. By online, we mean a user that is logged in, since there is also the possibility to log out (and back in).

You can now go into messaging mode when you want to send a message by pressing enter. Your current channel and your user ID will be shown in front of the message that you're about to send. At this point, it might be interesting to connect more clients to showcase other features

### Logging out
You can log out of the chatserver with the `/logout` command.
You can log in again by issuing the `/login [userId] [password]` command. When you log back in to the server and your account already exists, you will be put in the channel you logged out in. This way, you can immediately continue chatting with fellow peers.
## Channels
### Joining a channel
You can join or create another channel by using the `/join [channelName]` command. If the channel you specified does not exist yet, it will be created and you will be put in it. You will no longer be able to see messages that are sent in the previous channel when you switch. The last ten messages that are sent in each channel are stored by the server and shown to a user when they join a channel, so you don't miss out on what's going on.

### Keystroke Authentication
Messages sent by other users will show a ✓ or a ✘ symbol. The second symbol means that the sending user may not be the one he/she claims to be! This conclusion is based upon the fingertyping of the sending user. 

### Channel-related commands
A summary of all available channels can be seen with the `/channels` command. A list of online users in your current channel can be requested at any time with the `/users` command. This list is also shown when you join a different channel, as mentioned previously.

## Other Commands
You can express your feelings with commands such as `/tableflip`, `/tableunflip`, `/nyancat` and `/shrug`. 
Try `/pm [userId] [message]` to send a private message to someone else who is online. The receiving user can respond to you in private with `/reply [message]`. `/block [userId]` and `/unblock [userId]` allow you to block and ublock certain users. `/status [userId]` returns whether the user in question is online. The `/broadcast [message]` command can be used to send a message to every online user, no matter what channel they are in.

## Terminal Customization
Every user can easily customize its terminal with a bit of knowledge about programming. In the client websocket source file one can find following variables.
```js
const chatColor = reset; //is the standard terminal chat color
const othersColor = blue;
const myColor = cyan;
const channelColor = magenta;
const serverColor = red;
const succesColor = green;
```
Changing those will color the terminal otherwise.
As told above the application first shows the channel and then the sender's name. The position of all those elements are easily changed by moving them around in the array.
