diff --git a/package-lock.json b/package-lock.json index 570c7f0..bda00ac 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "@hibas123/realtimedb", - "version": "2.0.0-beta.20", + "version": "2.0.0-beta.21", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/src/database/database.ts b/src/database/database.ts index bf3e7a3..3e002ab 100644 --- a/src/database/database.ts +++ b/src/database/database.ts @@ -104,6 +104,8 @@ export class Database { return this.#rules; } + public connections = 0; + private locks = new DocumentLock(); public collectionLocks = new DocumentLock(); diff --git a/src/websocket.ts b/src/websocket.ts index 4ed7419..efab073 100644 --- a/src/websocket.ts +++ b/src/websocket.ts @@ -151,8 +151,9 @@ export class WebsocketConnectionManager { Logging.error(err); } }); - + db.connections++; socket.on("close", () => { + db.connections--; Logging.log(`${session.id} has disconnected!`); session.subscriptions.forEach((unsubscribe) => unsubscribe()); session.subscriptions.clear();