From 2f30b743f645c6fdbb5dbbc375dcd33ce54a62ae Mon Sep 17 00:00:00 2001 From: Derrick Hammer Date: Tue, 4 Apr 2023 11:22:37 -0400 Subject: [PATCH] *Move existing connection logic up --- src/index.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/index.ts b/src/index.ts index 35263e6..c3128b9 100644 --- a/src/index.ts +++ b/src/index.ts @@ -351,6 +351,12 @@ async function handleListenConnections(aq: ActiveQuery) { aq.respond(); }); + for (const conn of connections) { + if (conn[1].swarm === swarmId) { + listener(conn[1].conn); + } + } + const closeCb = () => { swarmEvent?.off("connection", listener); swarmEvent?.emit("close"); @@ -366,12 +372,6 @@ async function handleListenConnections(aq: ActiveQuery) { return; } swarm.onceSelf("ready", hookClose); - - for (const conn of connections) { - if (conn[1].swarm === swarmId) { - listener(conn[1].conn); - } - } } async function handleGetSocketInfo(aq: ActiveQuery) {