I want to have desktop applications be able to talk to each other, the plan will be to use a Relay to avoid any NAT issues.
I would like to connect Alice and Bob, both NodeJS client by using a custom relay (in golang)
I know my relay are operational because I made it work by splitting dialer/listener from the Go example code.
Regarding NodeJS Implementation I’m kind of lost, and I’m 10 times much experienced in JS.
The implementation in Go are logic and straight forward.
- Create a handler for each peers Alice and Bob
- Declare Alice to discover other peers from the relay.
- Connect both Alice and Bob peer to RELAY
- Connect Alice to Bob using /p2p-circuit/ multi-address
- Create a stream protocol /cat with PeerID Bob
- Enjoy the success working message printed on Bob when Alice dial
but the example is incomplete and show the creation of listener/dialer using Circuit object.
It’s different than using traditional Node listener because we have to manage
which is now known as
Switch and the lack of documentation found led me to reverse-engine the code to try to figure it out.
I don’t know if I must used Circuit inside the Node transports definition or not.
It should seems natural to me that peerBook are enough to connect nodes.
There are the echo code example I’m trying to make it work
Alice Peer: https://gist.github.com/Pierozi/cbf4a3ddb7f30c24a1f81889f4f53bd1
Bob Peer (dialer): https://gist.github.com/Pierozi/47b0e392dda9c0f70b6aff823e438174