Merge branch 'master' into '3-client-invisibility-is-not-implemented'
Replacing sgay's changes on map.html # Conflicts: # map.html
This commit is contained in:
commit
b301e77b84
2 changed files with 15 additions and 2 deletions
2
map.html
2
map.html
|
@ -101,6 +101,8 @@
|
|||
|
||||
socket.on("changeColor", function(data){
|
||||
console.log("changeColor", data);
|
||||
if(data.id in colors && colors[data.id] == -1 && data.id in markers)
|
||||
markers[data.id].addTo(map);
|
||||
colors[data.id] = data.color;
|
||||
if(data.id in markers){
|
||||
if(data.id == id)
|
||||
|
|
15
traque.js
15
traque.js
|
@ -59,11 +59,14 @@ io.sockets.on('connection', function(socket){
|
|||
equipes.push(socket);
|
||||
socket.shown = true;
|
||||
socket.color = 0;
|
||||
socket.position = [0,0];
|
||||
socket.on('geoLoc', function(d){
|
||||
socket.position = d.position;
|
||||
if(socket.shown)
|
||||
for(i in equipes)
|
||||
equipes[i].emit('moving', {"id": socket.id, "position": d.position});
|
||||
else
|
||||
socket.emit('moving', {"id": socket.id, "position": d.position});
|
||||
});
|
||||
socket.on('changeColor', function(d){
|
||||
socket.color = d.color - 0;
|
||||
|
@ -71,11 +74,11 @@ io.sockets.on('connection', function(socket){
|
|||
socket.shown = false;
|
||||
else{
|
||||
if(!socket.shown)
|
||||
for(i in equipes)
|
||||
for(i in equipes)
|
||||
equipes[i].emit('moving', {"id": socket.id, "position": socket.position});
|
||||
socket.shown = true;
|
||||
}
|
||||
for(i in equipes)
|
||||
for(i in equipes)
|
||||
equipes[i].emit('changeColor', {"id": socket.id, "color": d.color});
|
||||
});
|
||||
socket.on('setName', function(d){
|
||||
|
@ -83,7 +86,15 @@ io.sockets.on('connection', function(socket){
|
|||
for(i in equipes)
|
||||
equipes[i].emit('setName', {"id": socket.id, "name": d.name});
|
||||
});
|
||||
|
||||
socket.emit('yourId', {"id": socket.id});
|
||||
for(i in equipes){
|
||||
if(!equipes[i].shown)
|
||||
continue;
|
||||
socket.emit('setName', {"id": i, "name": equipes[i].name});
|
||||
socket.emit('changeColor', {"id": i, "color": equipes[i].color});
|
||||
socket.emit('moving', {"id": i, "position": equipes[i].position});
|
||||
}
|
||||
});
|
||||
|
||||
console.log("Launch server");
|
||||
|
|
Loading…
Reference in a new issue