
Show HN: P2p IRC-inspired browser chat on WebTorrent - chr15m
https://chr15m.github.io/dirc/#hn
======
yazr
How do u implement the list of rooms ?

Presumably, when a new room is created, this has to be broadcast to all users.

Also, i guess every chat line is kind of broadcast to everyone in the room. So
how do announce a new line is available?

Many thanks.

~~~
chr15m
When you join a room the room name is hashed and you join a WebTorrent swarm
based on that hash. So it's a collection of WebRTC peers who are connected to
eachother based upon the shared hash of the room name. Not every peer is
connected to every other peer.

So "when a new room is created, this has to be broadcast to all users" is not
quite right. A new swarm is created when a user joins a room-hash for the
first time and anybody who joins that same room-hash will be introduced to the
same swarm. People who have not joined the room-hash will not be part of the
p2p swarm.

Currently the hash-based WebRTC signalling that WebTorrent does to introduce
peers is quite centralized but the actual communication channels are
decentralized. The communication layer is implemented as a WebTorrent
"extension protocol" extension. This is the same model dreamtime:
[https://github.com/chr15m/dreamtime](https://github.com/chr15m/dreamtime)

You are correct that every chat line is broadcast to everyone in the same
swarm. In fact, every message is re-broadcast multiple times redundantly by
every peer who receives it for the first time, because the WebRTC swarm can be
fragmented. Not every peer can directly see every other peer so we must re-
broadcast everything to make sure everyone sees each line.

So basically for each room you have a set of peers (browsers) connected
together loosely with WebRTC data links and messages between them are sent
multiple times redundantly.

Thank you very much for your interest and for trying it out.

------
tomxor
[https://github.com/chr15m/dirc/](https://github.com/chr15m/dirc/)

------
maeln
Doesn't seem to work on Firefox 61.0.2 on Mac OS.

I can send message on Chromium but the chatroom seem empty. EDIT: Work on
Chromium :)

------
m-p-3

        Waiting for other participants...

On Firefox 61.0.2

    
    
        Firefox can’t establish a connection to the server at wss://tracker.fastcast.nz/. app.js:15:233483
        ICE failed, add a TURN server and see about:webrtc for more details

~~~
chr15m
The WebRTC signalling can take a long time (I've seen up to 2 minutes) because
your browser has to find a way that other browsers can tunnel in to your
network. Once you're connected messages seem to go through fairly quickly.

The fastcast.nz error is because that signalling server is down and has been
for a while but you can safely ignore it.

The "ICE failed" error might be because you are behind a very restrictive
firewall.

Thanks for trying it out!

------
thatcat
I like it! You might consider reformatting the description to be more like
/nick _handle_ // sets handle because it's kind of confusing with the = for
those that don't use irc much.

~~~
chr15m
Thanks for testing & for your feedback! I'll have a think about how to make
that clearer.

------
tribesman
I never found any p2p app with similar user experience as WhatsApp.

All people on this site brag of p2p and their technical prowness, yet no one
has managed to build a killer p2p chat app. Disgusting!

Probably, they are still debating what programing language to use.

~~~
askz
The challenge is yours, then!

~~~
tribesman
Yea, but I've no skills to make one. I am willing to pay for one, £1 per
month.

