Upon starting a connection, both peers join the default channel. This is for unique messages between specifically these 2 hosts. The channel is concerned with signalling for synchronization purposes.
spawn_channel(): create a new channel
close(): close the current channel
invite(): invite another host to the channel and become a relay for them.
receive(): receive message or event (such as host joined/left channel).
get_status(): return number of hosts in the channel
On top of this basic design we can create 3 patterns:
- async message passing
There is no concept of connection closed, just channels and active hosts (+ their unique channel ids generated per channel). When hosts disconnect or don't respond to pings, then they are kicked from the channel until they rejoin. The system is like IRC but with a p2p network model + automatic encryption.
spawn_channel()(usually we call this for the default channel on opening connection)
accept()handler in code is called for new channel invite