This program is a semestral project on MI-PYT and MI-DSV courses at FIT CTU in Prague. It is implemented in Python 3.7 and uses AsyncIO. Since a few new AsyncIO features were used in this program, it is necessary to have Python 3.7 or higher to run it.

This application is a CLI chat room program. However, it does not use a simple server-client way. All nodes are clients, any node can be a server from this point of view.

The chatroom is a network ring (a node only knows its next and previous node), however all nodes know the leader node (chat coordinator) as well in order to send it a message. The first node that creates the chatroom is automtically its leader. When the leader dies or logs out, the new leader is elected using Chang-Roberts leader election algorithm.


The program is uploaded on PyPI.

For the newest version, just type:

$ python -m pip install soucevi1_dist_chat

For any specific version, type:

$ python -m pip install soucevi1_dist_chat==<version>

You can also clone and use the GitHub repository.

Example usage

If you installed the program, you can create the room and chat!

Chatroom creation is very simple. You only need to run the leader node:

$ soucevi1_dist_chat -l -n Name -a -p 12345

The command above will run the leader node (-l) on IP address and port 12345 with username Name. The leader will listen and as soon as some other node makes a connection to it, the chat will start.

Then, you can start another node that will connect to the running leader:

$ soucevi1_dist_chat -n Name2 -a -p 54321 -na -np 12345

This node is run by a user called Name2 on As you can see, non-leader nodes need an address and a port of any node that is already participating in the chat in order to join the chatroom. If you want to read more about usage, read How To Use The Program. More about the inner implementation is in How the Program Works.

Indices and tables