Skip to content

Commit b14a2ff

Browse files
committed
docs(examples): transports 4
1 parent 7b78736 commit b14a2ff

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

examples/transports/README.md

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,8 @@ Let's update our flow to create nodes and see how they behave when dialing to ea
220220
```JavaScript
221221
parallel([
222222
(cb) => createNode('/ip4/0.0.0.0/tcp/0', cb),
223+
// Here we add an extra multiaddr that has a /ws at the end, this means that we want
224+
// to create a TCP socket, but mount it as WebSockets instead.
223225
(cb) => createNode(['/ip4/0.0.0.0/tcp/0', '/ip4/127.0.0.1/tcp/10000/ws'], cb),
224226
(cb) => createNode('/ip4/127.0.0.1/tcp/20000/ws', cb)
225227
], (err, nodes) => {
@@ -237,18 +239,21 @@ parallel([
237239
node2.handle('/print', print)
238240
node3.handle('/print', print)
239241

242+
// node 1 (TCP) dials to node 2 (TCP+WebSockets)
240243
node1.dial(node2.peerInfo, '/print', (err, conn) => {
241244
if (err) { throw err }
242245

243246
pull(pull.values(['node 1 dialed to node 2 successfully']), conn)
244247
})
245248

249+
// node 2 (TCP+WebSockets) dials to node 2 (WebSockets)
246250
node2.dial(node3.peerInfo, '/print', (err, conn) => {
247251
if (err) { throw err }
248252

249253
pull(pull.values(['node 2 dialed to node 3 successfully']), conn)
250254
})
251255

256+
// node 3 (WebSockets) attempts to dial to node 1 (TCP)
252257
node3.dial(node1.peerInfo, '/print', (err, conn) => {
253258
if (err) {
254259
console.log('node 3 failed to dial to node 1 with:', err.message)
@@ -291,7 +296,10 @@ As expected, we created 3 nodes, node 1 with TCP, node 2 with TCP+WebSockets and
291296

292297
## 4. How to create a new libp2p transport
293298

294-
- interface-transport
295-
- follow the interface
296-
- show other examples (webrtc, utp, udt (wip), etc)
297-
-
299+
Today there are already 3 transports available, one in the works and plenty to come, you can find these at [interface-transport implementations](https://github.com/libp2p/interface-transport#modules-that-implement-the-interface) list.
300+
301+
Adding more transports is done through the same way as you added TCP and WebSockets. Some transports might offer extra functionalities but for what is libp2p concern, as long as it follows the interface defined at the [spec](https://github.com/libp2p/interface-transport#api), it will be able to use it.
302+
303+
If you decide to implement a transport yourself, please consider adding to the list so that others can use it as well.
304+
305+
Hope this tutorial was useful. We are always looking to improve it, contributions are welcome!

0 commit comments

Comments
 (0)