Skip to content

Commit 43136b4

Browse files
committed
fix: correct stream handling and protocol dialing in example code
1 parent 20a2e1e commit 43136b4

File tree

1 file changed

+3
-3
lines changed
  • examples/js-libp2p-example-protocol-and-stream-muxing

1 file changed

+3
-3
lines changed

examples/js-libp2p-example-protocol-and-stream-muxing/1.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ node2.handle(['/another-protocol/1.0.0', '/another-protocol/2.0.0'], ({ protocol
4949
stream,
5050
async function (source) {
5151
for await (const msg of source) {
52-
console.log(uint8ArrayToString(msg))
52+
console.log(uint8ArrayToString(msg.subarray()))
5353
}
5454
}
5555
)
@@ -63,10 +63,10 @@ await pipe(
6363
)
6464

6565
/*
66-
const stream = node1.dialProtocol(node2.peerId, ['/another-protocol/1.0.0'])
66+
const stream = await node1.dialProtocol(node2.getMultiaddrs(), ['/another-protocol/1.0.0'])
6767
6868
await pipe(
69-
['my own protocol, wow!'],
69+
[uint8ArrayFromString('my own protocol, wow!')],
7070
stream
7171
)
7272
*/

0 commit comments

Comments
 (0)