My implementation of th P2P project was in command line based application. Using Python and the twisted.internet library, this application achives UDP transmission of messages without a persistent connection, or a server to central server
The architecture of this project consists of clients
to be able to create a server-less messaging application using any frameworks.
- Discovery & Login
- session connection
- chat
- file exchange
- local db
- offline synch
app.py
app.py was going to be a webbased implemention of the P2P application initially built in command line
client.py
client.py is contains the object class Client, which requires a username, host and port address.
currently every Client object is running on localhost, with addresses ranging from 127.0.0.1:5000 to 127.0.0.1:9998
worker.py
worker.py contains object class Worker, which runs soley to intialize Client object, return active clients from PING messages, and removing clients upon exit.
To run this project you need to.
- start the worker client by running
python worker.pyone terminal window - start as many clients on as many terminal windows. One client per terminal
python client.py - Follow the instructions on the command prompt
the command prompt will ask you to type the index the user's address is listed.
User address can be reloaded by inputting -1
In the example above, two clients connect and messaging each other. One client exits and returns to the connection prompt. they chose to load past conversations by inputting -2
All clients have storage for all chats with past users during their session. Chats are saved until the terminal window is closed
The worker client running on 127.0.0.1:9999 is responsible for handling
__INIT__ : Initialize Client objects with username, host, port
__PING__ : Return username to worker client to indicate client is alive
__RELOAD__ : Invoked by the web page to refresh all connections by pinging clients,