From 876d56b25a9e04fa1a24a75f4828458b67938081 Mon Sep 17 00:00:00 2001 From: Derrick Hammer Date: Sat, 8 Apr 2023 20:17:44 -0400 Subject: [PATCH] * Add `setupStream` to the list of imports and set up stream for `dhtInstance.swarm` when the "setup" event occurs. --- src/index.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/index.ts b/src/index.ts index 40a5282..6e880a5 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,7 +1,7 @@ import { addHandler, handleMessage } from "libkmodule"; import type { ActiveQuery } from "libkmodule"; import { createClient, SwarmClient } from "@lumeweb/kernel-swarm-client"; -import { RpcNetwork, RpcQueryOptions } from "@lumeweb/rpc-client"; +import { RpcNetwork, RpcQueryOptions, setupStream } from "@lumeweb/rpc-client"; import type { RPCRequest, RPCResponse } from "@lumeweb/interface-relay"; onmessage = handleMessage; @@ -98,6 +98,8 @@ async function createNetwork(def = true): Promise { const id = nextId(); networkInstances.set(id, dhtInstance); + dhtInstance.swarm.on("setup", async (peer: any) => setupStream(peer)); + return id; }