Beta to stable #5
			
				
			
		
		
		
	| 
						 | 
				
			
			@ -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"))
 | 
			
		||||
});
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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,
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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ı
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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');
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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({
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -0,0 +1 @@
 | 
			
		|||
exports.termoutput = false;
 | 
			
		||||
		Loading…
	
		Reference in New Issue