multitasking #7
			
				
			
		
		
		
	| 
						 | 
				
			
			@ -24,6 +24,9 @@ exports.http = server;
 | 
			
		|||
app.get("/script",(request, response)=>{
 | 
			
		||||
    response.sendFile(resolve("./script/index.js"))
 | 
			
		||||
});
 | 
			
		||||
app.get("/test",(request, response)=>{
 | 
			
		||||
    response.sendFile(resolve("./script/test.html"))
 | 
			
		||||
});
 | 
			
		||||
app.get("/index.js.map",(request, response)=>{
 | 
			
		||||
    response.sendFile(resolve("./script/index.js.map"))
 | 
			
		||||
});
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -20,7 +20,7 @@ process.on('message',data => {
 | 
			
		|||
            break;
 | 
			
		||||
        }
 | 
			
		||||
        case "CLIENT_SEND_MESSAGE":{
 | 
			
		||||
            slog("CLIENT_SEND_MESSAGE");
 | 
			
		||||
            //slog("CLIENT_SEND_MESSAGE");
 | 
			
		||||
            let client = Client.clients.get(data.uuid);
 | 
			
		||||
            if(client.isProxy != true)
 | 
			
		||||
            {
 | 
			
		||||
| 
						 | 
				
			
			@ -164,10 +164,12 @@ function ROOM_DESTROY(room)
 | 
			
		|||
 | 
			
		||||
function mlog(command)
 | 
			
		||||
{
 | 
			
		||||
    return;
 | 
			
		||||
    console.log("M",process.pid, command)
 | 
			
		||||
}
 | 
			
		||||
function slog(command)
 | 
			
		||||
{
 | 
			
		||||
    return;
 | 
			
		||||
    console.log("S",process.pid, command)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -87,7 +87,6 @@ addService(({
 | 
			
		|||
            let {to,pack, handshake,wom} = message;
 | 
			
		||||
            if(Room.rooms.has(to))
 | 
			
		||||
            {
 | 
			
		||||
                console.log("Oda da ", Room.rooms.get(to).clients.size,"kişi var")
 | 
			
		||||
                if(!client.rooms.has(to))
 | 
			
		||||
                {
 | 
			
		||||
                    return handshake && end({
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,3 +1,5 @@
 | 
			
		|||
const { mlog } = require("./IPC");
 | 
			
		||||
 | 
			
		||||
exports.ws_writed_bytes = 0;
 | 
			
		||||
exports.ws_readed_bytes = 0;
 | 
			
		||||
exports.ws_total_bytes = 0;
 | 
			
		||||
| 
						 | 
				
			
			@ -25,6 +27,7 @@ setInterval(()=>{
 | 
			
		|||
        ws_recaived_packs: exports.ws_recaived_packs,
 | 
			
		||||
        ws_total_packs: exports.ws_total_packs
 | 
			
		||||
    })
 | 
			
		||||
    mlog(`writed ${exports.ws_writed_bytes} bytes, readed ${exports.ws_readed_bytes} bytes`);
 | 
			
		||||
    exports.ws_writed_bytes = 0;
 | 
			
		||||
    exports.ws_readed_bytes = 0;
 | 
			
		||||
    exports.ws_total_bytes = 0;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										6
									
								
								index.js
								
								
								
								
							
							
						
						
									
										6
									
								
								index.js
								
								
								
								
							| 
						 | 
				
			
			@ -12,7 +12,7 @@ async function main()
 | 
			
		|||
{
 | 
			
		||||
    if(cluster.isPrimary == false)
 | 
			
		||||
    {
 | 
			
		||||
        console.log("Slave", process.pid);
 | 
			
		||||
        console.log("Slave Process PID:", process.pid);
 | 
			
		||||
        // This process is a worker / slave
 | 
			
		||||
        // Compile source code and run
 | 
			
		||||
        require("./Source/index");
 | 
			
		||||
| 
						 | 
				
			
			@ -21,12 +21,12 @@ async function main()
 | 
			
		|||
    };
 | 
			
		||||
 | 
			
		||||
    // This process is a primary / master
 | 
			
		||||
    console.log("Master", process.pid);
 | 
			
		||||
    console.log("Master Process PID:", process.pid);
 | 
			
		||||
 | 
			
		||||
    // Worker process list
 | 
			
		||||
    const master = new Map();
 | 
			
		||||
 | 
			
		||||
    const coreCount = os.cpus().length;
 | 
			
		||||
    const coreCount = 3 //os.cpus().length;
 | 
			
		||||
    for(let index = 0; index < coreCount; index++)
 | 
			
		||||
    {
 | 
			
		||||
        // Open slave process
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -669,7 +669,7 @@
 | 
			
		|||
                meters.set(core, meter)
 | 
			
		||||
            };
 | 
			
		||||
            let _meter = meters.get(core);
 | 
			
		||||
            _meter.update(ws_total_packs,0)
 | 
			
		||||
            _meter.update(ws_total_packs,ws_total_packs < 30 ? 0 : ws_total_packs < 60 ? 1 : ws_total_packs < 90 ? 2 : 3)
 | 
			
		||||
        }
 | 
			
		||||
       }
 | 
			
		||||
       reloadData();
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -9,7 +9,7 @@
 | 
			
		|||
<body>
 | 
			
		||||
    <h2><pre id="log"></pre></h2>
 | 
			
		||||
    <h1 id="message"></h1>
 | 
			
		||||
    <script src="./script/index.js"></script>
 | 
			
		||||
    <script src="http://localhost:7707/script"></script>
 | 
			
		||||
    <script>
 | 
			
		||||
        async function main(){
 | 
			
		||||
            const wsjs = new MWSE({
 | 
			
		||||
		Loading…
	
		Reference in New Issue