request game init from server

This commit is contained in:
2020-12-06 22:28:45 +01:00
parent abccd2e51a
commit bcfc488c2e
4 changed files with 53 additions and 17 deletions

View File

@ -30,16 +30,23 @@
//alert("[open] Connection established");
//alert("Sending to server");
//socket.send("My name is John");
var msg = {
type: "message",
fct: "requestInit",
};
let t = JSON.stringify(msg);
window.game_socket.send(t);
};
socket.onmessage = function(event) {
let x = JSON.parse(event.data);
let fct = x.fct;
let msg = JSON.parse(event.data);
let fct = msg.fct;
if (fct == "reload") {
location.reload(true);
}
else if (fct == "startGame") {
let names = "..."
let names = msg.names
setupGame(names)
}
else {
alert('unknown command: '+event.data);