mirror of
https://github.com/fluencelabs/js-libp2p
synced 2025-04-25 10:32:14 +00:00
docs: update transport example (#1268)
This commit is contained in:
parent
750ed9c35f
commit
6eaab2e3ee
@ -43,7 +43,7 @@ function print ({ stream }) {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
;(async () => {
|
(async () => {
|
||||||
const [node1, node2, node3] = await Promise.all([
|
const [node1, node2, node3] = await Promise.all([
|
||||||
createNode([new TCP()], '/ip4/0.0.0.0/tcp/0'),
|
createNode([new TCP()], '/ip4/0.0.0.0/tcp/0'),
|
||||||
createNode([new TCP(), new WebSockets()], ['/ip4/0.0.0.0/tcp/0', '/ip4/127.0.0.1/tcp/10000/ws']),
|
createNode([new TCP(), new WebSockets()], ['/ip4/0.0.0.0/tcp/0', '/ip4/127.0.0.1/tcp/10000/ws']),
|
||||||
@ -69,7 +69,7 @@ function print ({ stream }) {
|
|||||||
stream
|
stream
|
||||||
)
|
)
|
||||||
|
|
||||||
// node 2 (TCP+WebSockets) dials to node 2 (WebSockets)
|
// node 2 (TCP+WebSockets) dials to node 3 (WebSockets)
|
||||||
const stream2 = await node2.dialProtocol(node3.peerId, '/print')
|
const stream2 = await node2.dialProtocol(node3.peerId, '/print')
|
||||||
await pipe(
|
await pipe(
|
||||||
[uint8ArrayFromString('node 2 dialed to node 3 successfully')],
|
[uint8ArrayFromString('node 2 dialed to node 3 successfully')],
|
||||||
|
@ -121,7 +121,7 @@ function printAddrs (node, number) {
|
|||||||
Then add,
|
Then add,
|
||||||
|
|
||||||
```js
|
```js
|
||||||
;(async () => {
|
(async () => {
|
||||||
const [node1, node2] = await Promise.all([
|
const [node1, node2] = await Promise.all([
|
||||||
createNode(),
|
createNode(),
|
||||||
createNode()
|
createNode()
|
||||||
@ -231,7 +231,7 @@ await pipe(
|
|||||||
stream
|
stream
|
||||||
)
|
)
|
||||||
|
|
||||||
// node 2 (TCP+WebSockets) dials to node 2 (WebSockets)
|
// node 2 (TCP+WebSockets) dials to node 3 (WebSockets)
|
||||||
const stream2 = await node2.dialProtocol(node3.peerId, '/print')
|
const stream2 = await node2.dialProtocol(node3.peerId, '/print')
|
||||||
await pipe(
|
await pipe(
|
||||||
['node 2 dialed to node 3 successfully'],
|
['node 2 dialed to node 3 successfully'],
|
||||||
|
Loading…
x
Reference in New Issue
Block a user