It is an anonymous chat API based on P2P Network. Each peer can send messages on public chat room in anonymous way. The system allows the users to create new room, join in a room, leave a room and send a message on a room. As described in the AnonymousChat Java API.
- createRoom: create a public room.
- joinRoom: join in public room.
- leaveRoom: leave a public room.
- sendMessage: send a string message to all members of a a public room.
- destroyRoom: a peer can destroy a public room if it is the only member.
- leaveNetwork: a peer can leave netwok.
The project has been implemented with:
- Java 8
- Apache Maven
- Intelij IDEA IDE
- Tom p2p
- JUnit
- Docker
The main program is structured in four Java classes and two Java interfaces :
- AnonymousChat: the API that define all the operations of the project.
- AnonymousChatImpl : the implementation of the API.
- Message: a class thet contains all the informations about a message.
- MessageLister: the API that define the message listener.
- MessageListenerImpl: a simple implpementation of a method for parsing the messages.
- Room: a class that contains all the informations about a room.
- Terminal a terminal to interact with the system.
The project provide also the class AppTest which is a JUnit test case.
The project is based on creating an anonymous chat. Two peers can communicate anonymously provided there are at least three peers on the network. A newly created peer will automatically join the "forwarderRoom" room if its size is less than ten. When a peer wants to send a message inside a room he checks the size of it. If there is only another peer in the room where you want to send the message, to guarantee anonymity, the message will be forwarded to a peer in the "forwarderRoom" room and the latter will have the task of sending the message to the recipient. If in the room where you want to send a message there are at least other two peers, you will forward it to one of them who will have the task of sending it to the respective recipient.
First of all you can build your docker container:
docker build --no-cache -f "Dockerfile" -t anonymouschat .
After that you can start the master peer, in interactive mode (-i) and with two (-e) environment variables:
docker run -i --name MASTER-PEER -e MASTERIP="127.0.0.1" -e ID=0 anonymouschat
the MASTERIP environment variable is the master peer ip address and the ID environment variable is the unique id of your peer. Remember you have to run the master peer using the ID=0.
When master is started you have to check the ip address of your container:
- Check the docker :
docker ps
- Check the IP address:
docker inspect <container ID>
Now you can start your peers varying the unique peer id:
docker run -i --name PEER-1 -e MASTERIP="172.17.0.2" -e ID=1 anonymouschat
To run correctly the application you must run at least three peers.
Raffaele Ceruso: 0522500537
Giovanni Leo: 0522500538