diff --git a/Source/HTTPServer.js b/Source/HTTPServer.js index c0759c7..a28c886 100644 --- a/Source/HTTPServer.js +++ b/Source/HTTPServer.js @@ -3,6 +3,8 @@ let http = require("http"); let express = require("express"); let compression = require("compression"); +let {resolve} = require("path"); +const { termoutput } = require("./config"); let server = http.createServer(); let app = express(); server.addListener("request", app); @@ -10,12 +12,10 @@ app.use(compression({ level: 9 })); server.listen(7707,'0.0.0.0',() => { - console.log("HTTP Service Running..."); + termoutput && console.log("HTTP Service Running..."); }); exports.http = server; - -let {resolve} = require("path"); app.get("/script",(request, response)=>{ response.sendFile(resolve("./script/index.js")) }); diff --git a/Source/Services/Auth.js b/Source/Services/Auth.js index eb7a6b5..2254b1b 100644 --- a/Source/Services/Auth.js +++ b/Source/Services/Auth.js @@ -1,12 +1,6 @@ const { Client } = require("../Client.js"); let {addService, addListener} = require("../WebSocket.js"); -addListener('disconnect',(global, xClient)=>{ - for (const pair of xClient.pairs) { - - } -}) - addService(({ client, message, diff --git a/Source/Services/DataTransfer.js b/Source/Services/DataTransfer.js index 2cbb360..a97f32e 100644 --- a/Source/Services/DataTransfer.js +++ b/Source/Services/DataTransfer.js @@ -2,7 +2,6 @@ const { Client } = require("../Client.js"); let {randomUUID} = require("crypto"); let {addService,addListener} = require("../WebSocket.js"); const { Room } = require("./Room.js"); -let term = require("terminal-kit").terminal; /* Peer to peer veri aktarımı diff --git a/Source/Services/Room.js b/Source/Services/Room.js index 04a8693..98a1a43 100644 --- a/Source/Services/Room.js +++ b/Source/Services/Room.js @@ -2,6 +2,7 @@ const { Client } = require("../Client.js"); let {randomUUID,createHash} = require("crypto"); const joi = require("joi"); let {addService,addListener} = require("../WebSocket.js"); +const { termoutput } = require("../config.js"); let term = require("terminal-kit").terminal; function Sha256(update) @@ -69,7 +70,7 @@ function Room() */ Room.prototype.publish = function(room){ Room.rooms.set(this.id, this); - term.green("Room Published ").white(this.name," in ").yellow(this.clients.size).white(" clients")('\n'); + termoutput && term.green("Room Published ").white(this.name," in ").yellow(this.clients.size).white(" clients")('\n'); }; Room.prototype.toJSON = function(){ let obj = {}; @@ -90,7 +91,7 @@ Room.prototype.send = function(obj, withOut){ client.send(obj); } } - term.green("Room bulk message ").white(this.name," in ").yellow(this.clients.size + "").white(" clients")('\n'); + termoutput && term.green("Room bulk message ").white(this.name," in ").yellow(this.clients.size + "").white(" clients")('\n'); }; /** * @param {Client} client @@ -106,10 +107,10 @@ Room.prototype.join = function(client){ }; client.rooms.add(this.id); this.clients.set(client.id, client); - term.green("Client Room joined ").white(this.name," in ").yellow(this.clients.size + "").white(" clients")('\n'); + termoutput && term.green("Client Room joined ").white(this.name," in ").yellow(this.clients.size + "").white(" clients")('\n'); }; Room.prototype.down = function(){ - term.red("Room is downed ").red(this.name," in ").yellow(this.clients.size + "").red(" clients")('\n'); + termoutput && term.red("Room is downed ").red(this.name," in ").yellow(this.clients.size + "").red(" clients")('\n'); this.send([{ roomid: this.id, ownerid: this.owner.id @@ -134,10 +135,10 @@ Room.prototype.eject = function(client){ if(this.clients.size == 0) { this.down(); - term.red("Client Room closed ").red(this.name," at 0 clients")('\n'); + termoutput && term.red("Client Room closed ").red(this.name," at 0 clients")('\n'); } - term.red("Client Room ejected ").red(this.name," in ").yellow(this.clients.size + "").red(" clients")('\n'); + termoutput && term.red("Client Room ejected ").red(this.name," in ").yellow(this.clients.size + "").red(" clients")('\n'); }; /** diff --git a/Source/WebSocket.js b/Source/WebSocket.js index 5f6c1c6..6d94da1 100644 --- a/Source/WebSocket.js +++ b/Source/WebSocket.js @@ -4,11 +4,11 @@ let websocket = require("websocket"); let {http} = require("./HTTPServer"); let {randomUUID} = require("crypto"); const { Client } = require("./Client.js"); - -console.log("Web Socket Protocol is ready"); +const { termoutput } = require("./config"); +termoutput && console.log("Web Socket Protocol is ready"); http.addListener("upgrade",() => { - console.log("HTTP Upgrading to WebSocket"); + termoutput && console.log("HTTP Upgrading to WebSocket"); }) let wsServer = new websocket.server({ diff --git a/Source/config.js b/Source/config.js new file mode 100644 index 0000000..81463b8 --- /dev/null +++ b/Source/config.js @@ -0,0 +1 @@ +exports.termoutput = false; \ No newline at end of file