This commit is contained in:
Jarred Sumner
2024-11-28 00:40:17 -08:00
committed by snwy
parent 6cb1f66d43
commit 13aae6933d
2 changed files with 14 additions and 0 deletions

View File

@@ -5765,6 +5765,10 @@ pub fn NewServer(comptime NamespaceType: type, comptime ssl_enabled_: bool, comp
return JSValue.jsNumber(0);
}
if (this.config.websocket == null or this.app == null) {
return JSValue.jsNumber(0);
}
return JSValue.jsNumber((this.app.?.numSubscribers(topic.slice())));
}

View File

@@ -825,3 +825,13 @@ async function connect(server: Server): Promise<void> {
clients.push(client);
await promise;
}
it("you can call server.subscriberCount() when its not a websocket server", async () => {
const server = serve({
port: 0,
fetch(request, server) {
return new Response();
},
});
expect(server.subscriberCount("boop")).toBe(0);
});