9

I am writing a decentralized chat application using nodejs, expressjs, angularjs, socket.io and ipfs.I am using libp2p to form the nodes that will communicate with each other over an open connection. Libp2p is a networking stack modularized out of IPFS project.

Libp2p allows me to build nodes which are capable of hosting a swarm or listening/ dialing to one. I have developed to the point where several nodes can communicate with each other via inputs in angularjs (supplemented by socket.io) webpage but their IP addresses and tcp ports need to be hard coded.

The problem I am facing is, if an unknown number of users join this system and set up their nodes, how do I handle the scenario. I have done lot of research into DHT specifically into its application with torrents but am no where close to actually applying it.

I do not want to run a central system that keeps track of the users as a tracker keeps track of seeders and leachers in torrents (now somewhat redundant due to DHT)

In a centralized chat application, every time a user enters or leaves, I can send an emit event from the server to all peers using socket.io signaling the same. But the equivalent in a decentralized chat app is something I am struggling with greatly.

I need some guidance please.

Varun Agarwal
  • 1,587
  • 14
  • 29

1 Answers1

3

You won't have to worry about that issue specifically as libp2p will handle the discovery and connection of the nodes. In the end you get a primitive for process addressing which will always dial to the process if it is accessible in the network.

I've been working recently in better documentation and tutorials for libp2p, please go to https://github.com/libp2p/js-libp2p/tree/master/examples and https://github.com/libp2p/js-libp2p. More examples to come next week, including Peer Routing + Content Routing (aka DHT).

Cheers!

David Dias
  • 1,792
  • 3
  • 16
  • 28
  • Hi David. Thanks so much for the reply. Will definitely lookout for the example. Btw we have chat on webnode, several months ago and I had submitted this PR https://github.com/ipfs/js-libp2p-ipfs-nodejs/pull/39 . Would love to know, if I can help out/ contribute in this new repo. Do let me know. – Varun Agarwal Jul 10 '17 at 10:32
  • That's great! Hi again Varun! See the latest updates on https://github.com/libp2p/js-libp2p/issues/6#issuecomment-313970615, there are multiple things where you can help, have you checked the waffle board on https://waffle.io/libp2p/libp2p ? It contains all the issues from all the libp2p repos, so that it is easy to understand what is ready to be worked on and what is important. – David Dias Jul 11 '17 at 18:28