Loading events.js +12 −9 Original line number Diff line number Diff line Loading @@ -144,14 +144,14 @@ function createRouter(db) { res.header('Access-Control-Allow-Origin', "*").status(500).json({status: 'error in getMapInfo'}); } else { if (results.length === 1) { const average = results[0].average; const votes = results[0].votes; if (average !== null && votes !== null) { let average = results[0].average; let votes = results[0].votes; if (!average) average = 0; if (!votes) votes = 0; res.header('Access-Control-Allow-Origin', "*").status(200).json({votes: votes, average: average, vote: vote}); return; } } res.header('Access-Control-Allow-Origin', "*").status(500).json({status: 'error in getMapInfo'}); res.header('Access-Control-Allow-Origin', "*").status(500).json({status: 'unexpected result in getMapInfo'}); } }); } else { Loading @@ -172,15 +172,18 @@ function createRouter(db) { console.log(error); res.header('Access-Control-Allow-Origin', "*").status(500).json({status: 'error in getVote'}); } else { if (results.length < 2) { let vote = -1; if (results.length === 1) { const vote = results[0].vote; if (vote !== null) { vote = results[0].vote; } if (vote) { req.body.vote = vote; getMapInfo(req, res); return; } } res.header('Access-Control-Allow-Origin', "*").status(500).json({status: 'error in getVote'}); res.header('Access-Control-Allow-Origin', "*").status(500).json({status: 'unexpected result in getVote'}); } }); } else { Loading @@ -196,7 +199,7 @@ function createRouter(db) { router.get('/test', [test]); router.post('/setVote', [hasMap, hasVote, getMapInfo]); router.post('/getMapInfo', [getVote]); router.post('/getMapInfo', [hasMap, getVote]); return router; } Loading socket.js +2 −2 Original line number Diff line number Diff line Loading @@ -234,9 +234,9 @@ client.on('data',function(data){ // u can also => write the below code in seperate js file // open new node instance => and run it... // 87.78.129.86 // 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!'); testClient.write('Hello World Client!\r\n'); //test(testClient); Loading Loading
events.js +12 −9 Original line number Diff line number Diff line Loading @@ -144,14 +144,14 @@ function createRouter(db) { res.header('Access-Control-Allow-Origin', "*").status(500).json({status: 'error in getMapInfo'}); } else { if (results.length === 1) { const average = results[0].average; const votes = results[0].votes; if (average !== null && votes !== null) { let average = results[0].average; let votes = results[0].votes; if (!average) average = 0; if (!votes) votes = 0; res.header('Access-Control-Allow-Origin', "*").status(200).json({votes: votes, average: average, vote: vote}); return; } } res.header('Access-Control-Allow-Origin', "*").status(500).json({status: 'error in getMapInfo'}); res.header('Access-Control-Allow-Origin', "*").status(500).json({status: 'unexpected result in getMapInfo'}); } }); } else { Loading @@ -172,15 +172,18 @@ function createRouter(db) { console.log(error); res.header('Access-Control-Allow-Origin', "*").status(500).json({status: 'error in getVote'}); } else { if (results.length < 2) { let vote = -1; if (results.length === 1) { const vote = results[0].vote; if (vote !== null) { vote = results[0].vote; } if (vote) { req.body.vote = vote; getMapInfo(req, res); return; } } res.header('Access-Control-Allow-Origin', "*").status(500).json({status: 'error in getVote'}); res.header('Access-Control-Allow-Origin', "*").status(500).json({status: 'unexpected result in getVote'}); } }); } else { Loading @@ -196,7 +199,7 @@ function createRouter(db) { router.get('/test', [test]); router.post('/setVote', [hasMap, hasVote, getMapInfo]); router.post('/getMapInfo', [getVote]); router.post('/getMapInfo', [hasMap, getVote]); return router; } Loading
socket.js +2 −2 Original line number Diff line number Diff line Loading @@ -234,9 +234,9 @@ client.on('data',function(data){ // u can also => write the below code in seperate js file // open new node instance => and run it... // 87.78.129.86 // 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!'); testClient.write('Hello World Client!\r\n'); //test(testClient); Loading