Basic TCP chat server using the Twisted asynchronous I/O framework.
Features :-
- User registration and login (using a PLAIN TEXT password).
- DB persistence for user information and messages (SQLite).
- User > User and Broadcast messaging.
- Convenient DB operations using a light weight SQLite helper.
- Tracks last login/logout time and online status of a user.
Usage :
Setup :
-
Clone the repository
-
Set up a python virtual envrionment and activate it (https://realpython.com/blog/python/python-virtual-environments-a-primer/)
-
Install dependencies using the following command
pip install -r requirements.txt
-
Run the server using
python chatserver.py
-
Connect clients by typing this on a terminal
telnet <address> <port>
-
Enter username and password as follows. First time registers you, second onwards logs you in.
Enter
1. username:password to login or register
OR
2. .quit to exit
Input : michael:1234
Registration successful. Welcome michael
1 other users are online
Enter target_user>message to send a message
-
Enter
target>message
to send a message to the target username.
-
Default value for < port > is 1236.
-
< address > can be localhost if connecting from the same machine.
Simulating clients : (Because why not?)
After starting the server, run sim_client.py to simulate a number of clients. Internally, client auth is read from a configuration file (sim_users.json is the default).
Database :
The server creates and uses a SQLite database (default name is storage.db) for storing user information and messages.
Known limitations
The following, though easy enough, have not been implemented yet.
- Changing passwords.
- Viewing inbox, sent messages and other views.
- Message groups.
- Offline messaging.