diff --git a/Source/Services/Room.js b/Source/Services/Room.js index ec658e5..ff344df 100644 --- a/Source/Services/Room.js +++ b/Source/Services/Room.js @@ -5,6 +5,7 @@ let {addService,addListener} = require("../WebSocket.js"); const { termoutput } = require("../config.js"); const { ROOM_CREATED, ROOM_DESTROY, ROOM_UPDATE_PROP, ROOM_JOIN_CLIENT, ROOM_EJECT_CLIENT } = require("../IPC.js"); let term = require("terminal-kit").terminal; +const stats = require("../stats"); function Sha256(update) { @@ -78,6 +79,7 @@ function Room() * @param {Room} room */ Room.prototype.publish = function(room){ + stats.mwse_rooms++; Room.rooms.set(this.id, this); ROOM_CREATED(this); termoutput && term.green("Room Published ").white(this.name," in ").yellow(this.clients.size).white(" clients")('\n'); @@ -180,6 +182,7 @@ Room.prototype.down = function(){ },'room/closed']); Room.rooms.delete(this.id); ROOM_DESTROY(this) + stats.mwse_rooms--; }; /** * @param {Client} client diff --git a/Source/WebSocket.js b/Source/WebSocket.js index 0b5261d..516ad7f 100644 --- a/Source/WebSocket.js +++ b/Source/WebSocket.js @@ -42,6 +42,8 @@ wsServer.addListener("connect",(socket) => { Client.clients.set(id, xClient); clients.set(id, xClient); + stats.mwse_clients++; + CLIENT_CREATED(id); emit("connect", global, xClient); @@ -58,6 +60,7 @@ wsServer.addListener("connect",(socket) => { }, 1000) socket.addListener("close",()=>{ + stats.mwse_clients--; emit("disconnect", global, xClient); CLIENT_DESTROY(id); Client.clients.set(id, xClient); diff --git a/Source/stats.js b/Source/stats.js index fdf776c..94d9b13 100644 --- a/Source/stats.js +++ b/Source/stats.js @@ -6,6 +6,8 @@ exports.ws_total_bytes = 0; exports.ws_sended_packs = 0; exports.ws_recaived_packs = 0; exports.ws_total_packs = 0; +exports.mwse_rooms = 0; +exports.mwse_clients = 0; process.send({ @@ -15,7 +17,9 @@ process.send({ ws_total_bytes: exports.ws_total_bytes, ws_sended_packs: exports.ws_sended_packs, ws_recaived_packs: exports.ws_recaived_packs, - ws_total_packs: exports.ws_total_packs + ws_total_packs: exports.ws_total_packs, + mwse_rooms: exports.mwse_rooms, + mwse_clients: exports.mwse_clients }); setInterval(()=>{ process.send({ @@ -25,7 +29,9 @@ setInterval(()=>{ ws_total_bytes: exports.ws_total_bytes, ws_sended_packs: exports.ws_sended_packs, ws_recaived_packs: exports.ws_recaived_packs, - ws_total_packs: exports.ws_total_packs + ws_total_packs: exports.ws_total_packs, + mwse_rooms: exports.mwse_rooms, + mwse_clients: exports.mwse_clients }) mlog(`writed ${exports.ws_writed_bytes} bytes, readed ${exports.ws_readed_bytes} bytes`); exports.ws_writed_bytes = 0; @@ -34,6 +40,8 @@ setInterval(()=>{ exports.ws_sended_packs = 0; exports.ws_recaived_packs = 0; exports.ws_total_packs = 0; + exports.mwse_rooms = 0; + exports.mwse_clients = 0; process.send({ core: "readstat", ws_writed_bytes: exports.ws_writed_bytes, @@ -41,7 +49,9 @@ setInterval(()=>{ ws_total_bytes: exports.ws_total_bytes, ws_sended_packs: exports.ws_sended_packs, ws_recaived_packs: exports.ws_recaived_packs, - ws_total_packs: exports.ws_total_packs + ws_total_packs: exports.ws_total_packs, + mwse_rooms: exports.mwse_rooms, + mwse_clients: exports.mwse_clients }) }, 3000) diff --git a/frontend/Connection.ts b/frontend/Connection.ts index f60fa58..d8cd196 100644 --- a/frontend/Connection.ts +++ b/frontend/Connection.ts @@ -11,7 +11,7 @@ export class Connection public autoPair : boolean = false; public connected : boolean = false; - public autoReconnect : boolean = false; + public autoReconnect : boolean = true; public autoReconnectTimeout : number = 3000; public autoReconnectTimer? : number; constructor(options: IConnection){ diff --git a/script/index.html b/script/index.html index 9933e70..a1e59a1 100644 --- a/script/index.html +++ b/script/index.html @@ -11,6 +11,9 @@
+
+

Active R1: 0 R2: 0

+