Add connections stats
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Fabian Stamm 2020-12-11 18:00:14 +01:00
parent fcf8845664
commit f45746984f
3 changed files with 5 additions and 2 deletions

2
package-lock.json generated
View File

@ -1,6 +1,6 @@
{ {
"name": "@hibas123/realtimedb", "name": "@hibas123/realtimedb",
"version": "2.0.0-beta.20", "version": "2.0.0-beta.21",
"lockfileVersion": 1, "lockfileVersion": 1,
"requires": true, "requires": true,
"dependencies": { "dependencies": {

View File

@ -104,6 +104,8 @@ export class Database {
return this.#rules; return this.#rules;
} }
public connections = 0;
private locks = new DocumentLock(); private locks = new DocumentLock();
public collectionLocks = new DocumentLock(); public collectionLocks = new DocumentLock();

View File

@ -151,8 +151,9 @@ export class WebsocketConnectionManager {
Logging.error(err); Logging.error(err);
} }
}); });
db.connections++;
socket.on("close", () => { socket.on("close", () => {
db.connections--;
Logging.log(`${session.id} has disconnected!`); Logging.log(`${session.id} has disconnected!`);
session.subscriptions.forEach((unsubscribe) => unsubscribe()); session.subscriptions.forEach((unsubscribe) => unsubscribe());
session.subscriptions.clear(); session.subscriptions.clear();