Merge branch '1-server-new-clients-need-data-about-old-clients' into 'master'
send old data to new client Closes #1 See merge request sgay/traque!3
This commit is contained in:
commit
ae58a69b02
1 changed files with 11 additions and 2 deletions
|
@ -59,6 +59,7 @@ 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)
|
||||
|
@ -83,7 +84,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