Commit 9f0d0040 authored by Dennis Willers's avatar Dennis Willers 🏀

Synchronisation if new Game starts

parent 1fa02e50
Pipeline #336 passed with stages
in 3 minutes and 16 seconds
......@@ -274,6 +274,9 @@ function createRouter(db) {
res.header('Access-Control-Allow-Origin', "*").status(500).json({status: 'false'});
} else {
res.header('Access-Control-Allow-Origin', "*").status(200).json({status: 'true'});
socket.emit('newGame', {
sessionName: spielname
});
}
}
);
......
......@@ -16,8 +16,6 @@ var position = {
};
var currentCard = {};
var newRound = {};
var endRound = {};
Socketio.on("connection", socket => {
console.log('new Socket connect');
......@@ -48,32 +46,29 @@ Socketio.on("connection", socket => {
for (var key in currentCard) {
socket.emit(key, currentCard[key])
}
/*for (var key in newRound) {
socket.emit(key, newRound[key])
}
for (var key in endRound) {
socket.emit(key, endRound[key])
}*/
socket.on("newGame", data => {
console.log('New Game from: ', data.sessionName, ':newGame');
Socketio.emit(data.sessionName+":newGame", true);
socket.emit(data.sessionName+":newGame", true);
});
socket.on("newCard", data => {
console.log('New Card from: ', data, ':newCard');
console.log('New Card from: ', data.sessionName, ':newCard');
currentCard[data.sessionName+":newCard"] = data.cardID;
Socketio.emit(data.sessionName+":newCard", data.cardID)
});
socket.on("newRound", data => {
console.log('New Round from: ', data.isOpen);
endRound[data.sessionName+":endRound"] = false;
Socketio.emit(data.sessionName+":endRound", false);
socket.emit(data.sessionName+":endRound", false);
newRound[data.sessionName+":newRound"] = true;
Socketio.emit(data.sessionName+":newRound", true);
socket.emit(data.sessionName+":newRound", true);
Socketio.emit(data.sessionName+":newGame", false);
socket.emit(data.sessionName+":newGame", false);
});
socket.on("endRound", data => {
console.log('End Round from: ', data.isOpen);
newRound[data.sessionName+":newRound"] = false;
Socketio.emit(data.sessionName+":newRound", false);
socket.emit(data.sessionName+":newRound", false);
endRound[data.sessionName+":endRound"] = true;
Socketio.emit(data.sessionName+":endRound", true);
socket.emit(data.sessionName+":endRound", true);
});
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment