Impruvement statics
This commit is contained in:
parent
5a85be59e5
commit
6c2fb5eb68
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
|
|
@ -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){
|
||||
|
|
|
@ -11,6 +11,9 @@
|
|||
<div class="speed-container">
|
||||
|
||||
</div>
|
||||
<div class="connection-container">
|
||||
<h1>Active R1: <span id="roomCount">0</span> R2: <span id="connectionCount">0</span></h1>
|
||||
</div>
|
||||
</div>
|
||||
<style>
|
||||
html,body,#container{
|
||||
|
@ -19,6 +22,7 @@
|
|||
}
|
||||
#container{
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
.speed-container{
|
||||
display: flex;
|
||||
|
@ -26,6 +30,15 @@
|
|||
max-width: 1200px;
|
||||
flex-wrap: wrap;
|
||||
margin: auto;
|
||||
margin-top: auto;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
.connection-container{
|
||||
margin-top: 20px;
|
||||
margin-bottom: auto;
|
||||
text-align: center;
|
||||
font-family: system-ui;
|
||||
color: white;
|
||||
}
|
||||
.speed-container > div{
|
||||
flex: 1 1 25%;
|
||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue