Compare commits

..

No commits in common. "v0.1.0-develop.1" and "v0.0.2-develop.10" have entirely different histories.

4 changed files with 3 additions and 49 deletions

View File

@ -1,11 +1,3 @@
# [0.1.0-develop.1](https://git.lumeweb.com/LumeWeb/kernel-swarm/compare/v0.0.2-develop.10...v0.1.0-develop.1) (2023-07-22)
### Features
* add socketListeners api call ([e56cbec](https://git.lumeweb.com/LumeWeb/kernel-swarm/commit/e56cbecbcf6641ea12059868829b9428a3c327c2))
* track what modules are listening on a socket connection by their module id ([39a9114](https://git.lumeweb.com/LumeWeb/kernel-swarm/commit/39a91144de1641ec17ba02888409009310aca67a))
## [0.0.2-develop.10](https://git.lumeweb.com/LumeWeb/kernel-swarm/compare/v0.0.2-develop.9...v0.0.2-develop.10) (2023-07-22) ## [0.0.2-develop.10](https://git.lumeweb.com/LumeWeb/kernel-swarm/compare/v0.0.2-develop.9...v0.0.2-develop.10) (2023-07-22)

4
npm-shrinkwrap.json generated
View File

@ -1,12 +1,12 @@
{ {
"name": "@lumeweb/kernel-swarm", "name": "@lumeweb/kernel-swarm",
"version": "0.1.0-develop.1", "version": "0.0.2-develop.10",
"lockfileVersion": 3, "lockfileVersion": 3,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "@lumeweb/kernel-swarm", "name": "@lumeweb/kernel-swarm",
"version": "0.1.0-develop.1", "version": "0.0.2-develop.10",
"hasInstallScript": true, "hasInstallScript": true,
"dependencies": { "dependencies": {
"@lumeweb/hyperswarm-web": "0.0.2-develop.8", "@lumeweb/hyperswarm-web": "0.0.2-develop.8",

View File

@ -38,7 +38,7 @@
"patch-package": "^7.0.0", "patch-package": "^7.0.0",
"presetter": "*" "presetter": "*"
}, },
"version": "0.1.0-develop.1", "version": "0.0.2-develop.10",
"readme": "ERROR: No README data found!", "readme": "ERROR: No README data found!",
"overrides": { "overrides": {
"buffer": "^6.0.3" "buffer": "^6.0.3"

View File

@ -24,7 +24,6 @@ interface SwarmConnection {
swarm: number; swarm: number;
conn: any; conn: any;
channels: Map<number, Protomux>; channels: Map<number, Protomux>;
listeners: Map<string, number>;
} }
interface SwarmEvents { interface SwarmEvents {
@ -79,7 +78,6 @@ addHandler("socketExists", handleSocketExists);
addHandler("socketListenEvent", handleSocketListenEvent, { addHandler("socketListenEvent", handleSocketListenEvent, {
receiveUpdates: true, receiveUpdates: true,
}); });
addHandler("socketListeners", handleSocketListenersEvent);
addHandler("socketWrite", handleWriteSocketEvent); addHandler("socketWrite", handleWriteSocketEvent);
addHandler("socketClose", handleCloseSocketEvent); addHandler("socketClose", handleCloseSocketEvent);
addHandler("createProtomuxChannel", handleCreateProtomuxChannel, { addHandler("createProtomuxChannel", handleCreateProtomuxChannel, {
@ -124,7 +122,6 @@ async function createSwarm(): Promise<number> {
swarm: id, swarm: id,
conn: peer, conn: peer,
channels: new Map<number, Protomux>(), channels: new Map<number, Protomux>(),
listeners: new Map<string, number>(),
}); });
peer.once("close", () => { peer.once("close", () => {
@ -158,8 +155,6 @@ function handleSocketListenEvent(aq: ActiveQuery) {
return; return;
} }
const conn = connections.get(aq.callerInput.id) as SwarmConnection;
let responded = false; let responded = false;
const respond = () => { const respond = () => {
if (responded) { if (responded) {
@ -167,15 +162,6 @@ function handleSocketListenEvent(aq: ActiveQuery) {
} }
responded = true; responded = true;
let count = conn.listeners.get(aq.domain) as number;
count--;
if (count > 0) {
conn.listeners.set(aq.domain, count);
} else {
conn.listeners.delete(aq.domain);
}
aq.respond(); aq.respond();
}; };
@ -196,30 +182,6 @@ function handleSocketListenEvent(aq: ActiveQuery) {
socket.off(event, cb); socket.off(event, cb);
respond(); respond();
}); });
if (!conn.listeners.has(aq.domain)) {
conn.listeners.set(aq.domain, 0);
}
conn.listeners.set(aq.domain, (conn.listeners.get(aq.domain) as number) + 1);
}
async function handleSocketListenersEvent(aq: ActiveQuery) {
const socket = validateConnection(aq);
if (!socket) {
return;
}
const conn = connections.get(aq.callerInput.id) as SwarmConnection;
aq.respond(
[...conn.listeners.entries()]
.filter((item) => {
return item[1] > 0;
})
.map((item) => item[0]),
);
} }
async function handleSocketExists(aq: ActiveQuery) { async function handleSocketExists(aq: ActiveQuery) {