corrected most bugs

This commit is contained in:
catvayor 2022-09-09 13:03:08 +02:00
parent 3f9e2e8a2b
commit e7bf3c4684
5 changed files with 140 additions and 11 deletions

33
certif/server.crt Normal file
View file

@ -0,0 +1,33 @@
-----BEGIN CERTIFICATE-----
MIIFuzCCA6MCFFf0hYvQbhdf9bsR7jRMEwCjLZCtMA0GCSqGSIb3DQEBCwUAMIGZ
MQswCQYDVQQGEwJGUjEWMBQGA1UECAwNaWxlIGRlIGZyYW5jZTEOMAwGA1UEBwwF
UGFyaXMxDDAKBgNVBAoMA0VOUzESMBAGA1UECwwJY2x1YiBqZXV4MRUwEwYDVQQD
DAxyZXNwbyB0cmFxdWUxKTAnBgkqhkiG9w0BCQEWGmxiYWlsbHlAY2xpcHBlci5l
bnMucHNsLmV1MB4XDTIyMDkwOTA4MDIyMloXDTIzMDkwOTA4MDIyMlowgZkxCzAJ
BgNVBAYTAkZSMRYwFAYDVQQIDA1pbGUgZGUgZnJhbmNlMQ4wDAYDVQQHDAVQYXJp
czEMMAoGA1UECgwDRU5TMRIwEAYDVQQLDAljbHViIGpldXgxFTATBgNVBAMMDHJl
c3BvIHRyYXF1ZTEpMCcGCSqGSIb3DQEJARYabGJhaWxseUBjbGlwcGVyLmVucy5w
c2wuZXUwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQC2CRx4KgrmUc2/
MIW68AiNjCjZ+nN9WKCvVfPIrL0EeCyjEwScRfcG3gGYIl7CWQUuG9looWTnuxUD
wT92I6PI2mz5CjxzogvNIht4ZumbFesFWzWS58HUhUHDW1yijilmbxNoPnxIC+zo
XsO0vGD10fqBXsOonIs+ccsvfV0p9e1No4LuA6KvMGlMdHMIgYYiloCf7sZkgFRV
BVOJYwHGA2Se02zCR1zd7rEd1yJQIIixz6jHG5aGidS9FYu8M8wWyZdNFmneQEKx
Y3jY9CZkey7w0BzGdfJ9nBkt9VJYX69RgdIMfHzJnLUNTrC5DKqXprzPEGzGWVDx
6VCGwX+DpiQtW4z85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ApO0NMjiEVF+BdNHl
FunEix38l113MvLyS7RVIoSGc9QUZ0yU8zw6UpiBmiiDKaTg6SHUxkXGlm0GbgXL
cS2jfZUKfxwAQFmNJXeBnqmeTKWchbXt312SkNrx3VAVNOiG7mk6SS9vdyl9Z6Mo
hx0TUAyFVvF7QGrSSxrYQkL105lD3VvhYk3upKULDMaPgOFwHmJItlUFKjNnKtuF
l1pHYyErI6HTqo1/BvC6Gn1fHqk/Kro5JLEscFBrp029U4tCGL3iMXeFallOhd02
0T8ktd6ZrZZ8e7Y1DxCFmex39+rGGRnF18/RZD3gBoSmK5kd/lpF5ctxkwims5iY
XhKcF4emHt145p5/rXvPaLDpBO2O7r91iCK4eeCNNbCQD+VpCEMx6UQB52FFmdcA
3eSFFKZ8NrQsc3mThnAaGV2KhwpLcsZ+SpGHwkAhkqpz4UFFlvrsMzHKh4WWE+6G
otbmWTvXrXWrAlF3mAakgxZ6LhVxyfxsscXLWYcFPGBly4xruZ18r/g28IWBDEj4
+UlhYicNF43dWVL19/xKR2CV8kQLvqMJDzDSeZPvoxU6a+lYptotUgSxXKa8/LRB
ApWOhyxQvVpPMc8uLGRtrwIkJhg7HTxGy1PumKYg/1jd5blpYzdTkYYHrbV37shE
I5rS
-----END CERTIFICATE REQUEST-----

51
certif/server.key Normal file
View file

@ -0,0 +1,51 @@
-----BEGIN RSA PRIVATE KEY-----
MIIJKQIBAAKCAgEAtgkceCoK5lHNvzCFuvAIjYwo2fpzfVigr1XzyKy9BHgsoxME
nEX3Bt4BmCJewlkFLhvZaKFk57sVA8E/diOjyNps+Qo8c6ILzSIbeGbpmxXrBVs1
kufB1IVBw1tcoo4pZm8TaD58SAvs6F7DtLxg9dH6gV7DqJyLPnHLL31dKfXtTaOC
7gOirzBpTHRzCIGGIpaAn+7GZIBUVQVTiWMBxgNkntNswkdc3e6xHdciUCCIsc+o
xxuWhonUvRWLvDPMFsmXTRZp3kBCsWN42PQmZHsu8NAcxnXyfZwZLfVSWF+vUYHS
DHx8y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2G
8SU8zQKCAQAyUgE0PFfKyvJ5kVSP6mxcz0Fom4nVAfNJ7nmTmQxKYBXZcWzas6I8
OgwxRWNXdg6QKRM7I3yYryYpuGGNsh8cxY1Gc7Ex0dWXDim1CBoxW47PwnT0lFJt
vzi78aMJ4UmH2AJfiqpY6snGUh/tWGn6wptdvID1/CL/WJQxycuc5TXxJO5xH7pV
UcwkN36Xf0P2TOjeRvbptxxtiSP7U/SQnK0lErVoHGQGEP9IcrCAgadIronylGvR
IpjmUPzvCdIu5Uy8L5OUWOcpmUYCfBdyIk+2OxD3SC71GGZLTNPbJX0yViyH67F+
XgIt8M0oxR6w6HDvKp3ralc5n57AtnRpAoIBAQCywRu+VbKtVG2caRP1CS2J65AC
CYQcNxxvjAP746I7nQ0+e2AVDJC27M9b772xHx8xv3wFqPdBCO7QT8PtqjA6PIs6
6CosxfQDzqQv9gQJyQErbc6zhZZknh09dYTYYs/LbRGme7/dxNOd/6Wn5tKPv5oH
17emzGqCJifRkfmeicfo03egIYvHSy3sZIEllIRtC6wLzy7ovm/4aHFAVBtH07je
BXEoFHXIvh+XQieY7HjGmVekIrpFpvjJXAIm/XEXXitfnHB7r6UF1WehnrThgQNL
aWPc/+TBAW0blXuCXVmjro3oyU9sm5egOy0YS5b+JTyz50mnyV0ZsWc90kQP
-----END RSA PRIVATE KEY-----

View file

@ -24,13 +24,15 @@
<div id="map"></div><br/> <div id="map"></div><br/>
<input id="name"/><button id="setName">Set team name</button><br/> <input id="name"/><button id="setName">Set team name</button><br/>
<input type="number" name="color" value="0"/><button id="setColor">Set color</button><br/> <input type="number" id="color" value="0"/><button id="setColor">Set color</button><br/>
<script type="text/javascript"> <script type="text/javascript">
var protocol = "http";
var protocol = "https";
var server = "localhost"; var server = "localhost";
var port = "9000"; var port = "9000";
var socket = io.connect(protocol+"://"+server+":"+port); var socket = io.connect({rejectUnauthorized: false},
protocol+"://"+server+":"+port);
var id = -1; var id = -1;
var names = {}; var names = {};
@ -106,21 +108,22 @@
document.querySelector('#setColor').addEventListener('click', function(){ document.querySelector('#setColor').addEventListener('click', function(){
const input = document.querySelector('#color'); const input = document.querySelector('#color');
socket.emit("setColor", {"color": input.value}); socket.emit("changeColor", {"color": input.value});
}); });
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
// GEOLOCALISATION // GEOLOCALISATION
function geoLoc_success(pos) { function geoLoc_success(pos) {
socket.emit("geoLoc", {"position": pos}); console.log(pos);
socket.emit("geoLoc", {"position": [pos.coords.latitude, pos.coords.longitude]});
} }
function geoLoc_error(err) { function geoLoc_error(err) {
console.error(`ERROR(${err.code}): ${err.message}`); console.error(`ERROR(${err.code}): ${err.message}`);
} }
options = { var options = {
enableHighAccuracy: false, enableHighAccuracy: false,
timeout: 5000, timeout: 5000,
maximumAge: 0 maximumAge: 0

View file

@ -20,14 +20,19 @@ Les messages à transmettre par le serveur :
var equipes = []; var equipes = [];
// require = include // require = include
var http = require('http'); var http = require('https');//require('http');
var url = require('url'); var url = require('url');
var fs = require('fs'); var fs = require('fs');
console.log("Setup http server"); console.log("Setup http server");
const option = {
key: fs.readFileSync('certif/server.key'),
cert: fs.readFileSync('certif/server.crt')
};
// The server // The server
var server = http.createServer(function(req, res){ var server = http.createServer(option, function(req, res){
var q = url.parse(req.url, true); var q = url.parse(req.url, true);
var filename = "." + q.pathname; var filename = "." + q.pathname;
if(q.pathname == "/") if(q.pathname == "/")
@ -49,30 +54,38 @@ var io = new Server(server);
console.log("Setup handlers"); console.log("Setup handlers");
io.sockets.on('connection', function(socket){ io.sockets.on('connection', function(socket){
console.log("connection !");
socket.id = equipes.length; socket.id = equipes.length;
equipes.push(socket); equipes.push(socket);
socket.shown = false; socket.shown = true;
socket.color = 0; socket.color = 0;
socket.on('geoLoc', function(d){ socket.on('geoLoc', function(d){
console.log("new loc :", d);
socket.position = d.position; socket.position = d.position;
if(socket.shown) if(socket.shown)
for(i in equipes) for(i in equipes)
equipes[i].emit('moving', {"id": socket.id, "position": d.position}); equipes[i].emit('moving', {"id": socket.id, "position": d.position});
}); });
socket.on('changeColor', function(d){ socket.on('changeColor', function(d){
socket.color = d.color; console.log(d);
socket.color = d.color - 0;
console.log("new color2");
if(d.color == -1) if(d.color == -1)
socket.shown = false; socket.shown = false;
else{ else{
console.log("new color3");
if(!socket.shown) if(!socket.shown)
for(i in equipes) for(i in equipes)
equipes[i].emit('moving', {"id": socket.id, "position": socket.position}); equipes[i].emit('moving', {"id": socket.id, "position": socket.position});
socket.shown = true; socket.shown = true;
console.log("new color4");
} }
for(i in equipes) for(i in equipes)
equipes[i].emit('changeColor', {"id": socket.id, "color": d.color}); equipes[i].emit('changeColor', {"id": socket.id, "color": d.color});
console.log("new color5");
}); });
socket.on('setName', function(d){ socket.on('setName', function(d){
console.log("new name");
socket.name = d.name; socket.name = d.name;
for(i in equipes) for(i in equipes)
equipes[i].emit('setName', {"id": socket.id, "name": d.name}); equipes[i].emit('setName', {"id": socket.id, "name": d.name});