Commit 02019657 authored by Dennis Willers's avatar Dennis Willers
Browse files

Multiplayer send only if a new Vote comes

parent 8a4896a0
Loading
Loading
Loading
Loading
+11 −7
Original line number Original line Diff line number Diff line
@@ -83,14 +83,18 @@ server.on('connection',function(socket){
                    const req = JSON.parse(data);
                    const req = JSON.parse(data);
                    hf.addMapToClient(clients, socket, req['mapId'], newClientList => {
                    hf.addMapToClient(clients, socket, req['mapId'], newClientList => {
                        clients = newClientList.slice();
                        clients = newClientList.slice();
                        if (hf.checkIfRequestHasVote(data)) {
                            sendToAllClientsAtSameMap(res, req['mapId']);
                            sendToAllClientsAtSameMap(res, req['mapId']);
                    });
                    /*var is_kernel_buffer_full = socket.write(JSON.stringify(res.data) + '\n');
                    if(is_kernel_buffer_full){
                        console.log('Data was flushed successfully from kernel buffer i.e written successfully!');
                        } else {
                        } else {
                        socket.pause();
                            socket.write(JSON.stringify(res.data) + '\n');
                    }*/
                        }
                    });
                    //var is_kernel_buffer_full = socket.write(JSON.stringify(res.data) + '\n');
                    //if(is_kernel_buffer_full){
                    //    console.log('Data was flushed successfully from kernel buffer i.e written successfully!');
                    //} else {
                    //    socket.pause();
                    //}
                } else {
                } else {
                    console.log("Res was null");
                    console.log("Res was null");
                }
                }
@@ -250,7 +254,7 @@ client.on('data',function(data){


// 87.78.129.86  | localhost
// 87.78.129.86  | localhost


const testClient = net.connect({host: 'localhost', port: 3000}, () => {
/*const testClient = net.connect({host: '87.78.129.86', port: 3201}, () => {
    console.log('connected to server!');
    console.log('connected to server!');
    //testClient.write('Hello World Client!\r\n');
    //testClient.write('Hello World Client!\r\n');
    testClient.write(JSON.stringify({"mapId":"7fsfRSUCQ7YwfBEdRk_GivW6qzj","userId":"aKBNg9fbReqLedLiz1KFfA","name":"Summer 2021 - 01"}));
    testClient.write(JSON.stringify({"mapId":"7fsfRSUCQ7YwfBEdRk_GivW6qzj","userId":"aKBNg9fbReqLedLiz1KFfA","name":"Summer 2021 - 01"}));