Create a software tool for exchanging text messages that works on a local network in peer-to-peer mode. Each messaging participant (node) is identified by an IP address and an arbitrary name that is specified by the user (via a command line parameter). Names are not required to be unique. Each node uses UDP to form a list of active nodes (IP addresses and names):
- once started, the node sends a broadcast packet containing its name to notify other nodes on the network of its connection to the network;
- other nodes that receive such a packet establish a TCP connection for messaging with the sender and send their name over it for identification in the chat.
A new client can join the chat at any time. Messages are exchanged using TCP in a logically shared space: each node maintains one TCP connection with every other node and sends its messages to all nodes in the network. Disabling a node must be correctly handled by other nodes.
- Clone project to your folder:
git clone https://github.com/amarjin6/chat-room.git
- Check for updates and install all necessary plugins
- Run project
python chat.py [host] [username]
Connection established automatically after each member joins chat
Example: New member joined chat
python chat.py 127.0.0.1 Alex
Alex joined chat
Warning
Don't use the same host for multiple members!
After connection to the server, you can easily communicate with all members in the chat
Example: Alex 'Hello, it's ME!'
hh:mm:ss Alex: Hello, it's ME!
There you can see the time, when each member sent the message
Note
For more functionality use active commands
This command shows all active members with their IP's in the chat
/members
All active memebers:
Alex: 127.0.0.1
Tim: 127.0.0.2
John: 127.0.0.3
This command shows active commands toolbar
👼Welcome to the chat!👼
Here are some tips for YOU:
‣ /members - Show all connected members
‣ /help - Show this message
‣ /hooray - Beautiful greeting message
‣ /history - Request history from members
‣ /exit - Leave chat
This command shows beautiful greeting message
/hooray
Lorem ipsum dolor sit amet consectetur adipisicing elit. Maxime mollitia, molestiae quas vel sint commodi repudiandae consequuntur voluptatum laborum numquam blanditiis harum quisquam eius sed odit fugiat iusto fuga praesentiumoptio, eaque rerum! Provident similique accusantium nemo autem.
This command shows request history from members
/history
hh:mm:ss Alex: Hello, it's ME!
hh:mm:ss Tim: Hello, Alex
hh:mm:ss John: Hi!
With the help of this command you can leave chat
/exit
Alex left chat
Note
This message shows even if you stops programm