diff --git a/host/admind/admin.ws.js b/host/admind/admin.ws.js index a58f956..a447966 100644 --- a/host/admind/admin.ws.js +++ b/host/admind/admin.ws.js @@ -33,30 +33,30 @@ console.log("リセットボタンを押したしたよ"); ws.send("リセットお願い"); }); - window.onload = function () { - function Decode(value) { - //JSON ⇒ オブジェクト - //エンコードされたデータを元の形式へ戻す。(デコード) - var obj2 = JSON.parse(value.data); - return obj2; - } - ws.onmessage = function (e) { - console.log(e.data); - if (e.data == "リセットされたよ") { - coment.innerHTML = e.data; - console.log("リセットしたよ"); - } else { - AUDIO.pause(); - var userinfo = Decode(e); - console.log(userinfo); - coment.innerHTML = Object.keys(userinfo) + "が押しました!!"; - var team = document.getElementById("team").value; - if (team == userinfo.true) { - btn.disabled = true; - } + + function Decode(value) { + //JSON ⇒ オブジェクト + //エンコードされたデータを元の形式へ戻す。(デコード) + var obj2 = JSON.parse(value.data); + return obj2; + } + ws.onmessage = function (e) { + console.log(e.data); + if (e.data == "リセットされたよ") { + coment.innerHTML = e.data; + console.log("リセットしたよ"); + } else { + AUDIO.pause(); + var userinfo = Decode(e); + console.log(userinfo); + coment.innerHTML = Object.keys(userinfo) + "が押しました!!"; + var team = document.getElementById("team").value; + if (team == userinfo.true) { + btn.disabled = true; } - }; + } }; + } document.addEventListener("DOMContentLoaded", intro, false); diff --git a/server/ws.rb b/server/ws.rb index 2a8265e..b745fbc 100755 --- a/server/ws.rb +++ b/server/ws.rb @@ -38,10 +38,11 @@ if admin_pages == 2 then puts "Admin page opened, closing all clients..." connections.each do |client| - client.close unless client == ws_conn # 自分以外のクライアントをクローズ + client.close end admin_pages = 0 end + connections.clear else hash[message] = true str = JSON.generate(hash)