diff --git a/src/index.ts b/src/index.ts index bea1f53..6af15b0 100644 --- a/src/index.ts +++ b/src/index.ts @@ -26,6 +26,7 @@ addHandler("connect", handleConnect); addHandler("listenSocketEvent", handleListenSocketEvent, { receiveUpdates: true, }); +addHandler("socketExists", handleSocketExists); addHandler("close", handleCloseSocketEvent); addHandler("write", handleWriteSocketEvent); addHandler("addRelay", handleAddRelay); @@ -149,6 +150,12 @@ function handleListenSocketEvent(aq: ActiveQuery) { }); } +async function handleSocketExists(aq: ActiveQuery) { + const { id = null } = aq.callerInput; + + aq.respond(hasDhtConnection(Number(id))); +} + function handleCloseSocketEvent(aq: ActiveQuery) { const socket = validateConnection(aq);