Skip to content

Commit

Permalink
fix: canvas example; pubsub topic discovery v11.0.0 alternative (#186)
Browse files Browse the repository at this point in the history
  • Loading branch information
d-roak authored Oct 5, 2024
1 parent 23d0718 commit 21c32e4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
4 changes: 2 additions & 2 deletions examples/canvas/src/objects/canvas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,12 @@ export class Canvas implements CRO {
if (!op.value) continue;
switch (op.type) {
case "splash": {
const [nodeId, offset, size, rgb] = op.value;
const [offset, size, rgb] = op.value;
this._splash(offset, size, rgb);
break;
}
case "paint": {
const [nodeId, offset, rgb] = op.value;
const [offset, rgb] = op.value;
this._paint(offset, rgb);
break;
}
Expand Down
10 changes: 7 additions & 3 deletions packages/network/src/node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,13 @@ export class TopologyNetworkNode {
this._node.addEventListener("peer:connect", (e) =>
console.log("::start::peer::connect", e.detail),
);
this._node.addEventListener("peer:discovery", (e) =>
console.log("::start::peer::discovery", e.detail),
);
this._node.addEventListener("peer:discovery", (e) => {
// current bug in v11.0.0 requires manual dial (https://github.com/libp2p/js-libp2p-pubsub-peer-discovery/issues/149)
for (const ma of e.detail.multiaddrs) {
this._node?.dial(ma);
}
console.log("::start::peer::discovery", e.detail);
});
this._node.addEventListener("peer:identify", (e) =>
console.log("::start::peer::identify", e.detail),
);
Expand Down

0 comments on commit 21c32e4

Please sign in to comment.