diff --git a/examples/js-libp2p-example-protocol-and-stream-muxing/1.js b/examples/js-libp2p-example-protocol-and-stream-muxing/1.js index a80ccf2..357e125 100644 --- a/examples/js-libp2p-example-protocol-and-stream-muxing/1.js +++ b/examples/js-libp2p-example-protocol-and-stream-muxing/1.js @@ -49,7 +49,7 @@ node2.handle(['/another-protocol/1.0.0', '/another-protocol/2.0.0'], ({ protocol stream, async function (source) { for await (const msg of source) { - console.log(uint8ArrayToString(msg)) + console.log(uint8ArrayToString(msg.subarray())) } } ) @@ -63,10 +63,10 @@ await pipe( ) /* -const stream = node1.dialProtocol(node2.peerId, ['/another-protocol/1.0.0']) +const stream = await node1.dialProtocol(node2.getMultiaddrs(), ['/another-protocol/1.0.0']) await pipe( - ['my own protocol, wow!'], + [uint8ArrayFromString('my own protocol, wow!')], stream ) */ diff --git a/examples/js-libp2p-example-protocol-and-stream-muxing/2.js b/examples/js-libp2p-example-protocol-and-stream-muxing/2.js index 3f4a011..cde99d8 100644 --- a/examples/js-libp2p-example-protocol-and-stream-muxing/2.js +++ b/examples/js-libp2p-example-protocol-and-stream-muxing/2.js @@ -31,12 +31,12 @@ await node1.peerStore.patch(node2.peerId, { multiaddrs: node2.getMultiaddrs() }) -node2.handle(['/a', '/b'], ({ protocol, stream }) => { +node2.handle(['/a', '/b'], ({ stream }) => { pipe( stream, async function (source) { for await (const msg of source) { - console.log(`from: ${protocol}, msg: ${uint8ArrayToString(msg.subarray())}`) + console.log(`from: ${stream.protocol}, msg: ${uint8ArrayToString(msg.subarray())}`) } } ).finally(() => {