diff --git a/client/main.js b/client/main.js index 2f93681..7facaf9 100644 --- a/client/main.js +++ b/client/main.js @@ -101,6 +101,9 @@ const socket = io({ }); socket.on('connect', function () { console.log('connected'); + $(window).focus(function () { + socket.emit('history', current); + }); }); socket.on('disconnect', function () { console.log('disconnected'); @@ -114,6 +117,10 @@ socket.on('info', function (res) { drawGame() }); +socket.on('history', function (h) { + history = h; +}); + socket.on('players', function (p) { players = p; }); diff --git a/server.js b/server.js index 0153785..bf243b6 100644 --- a/server.js +++ b/server.js @@ -160,6 +160,10 @@ io.on('connection', function (socket) { hsize:HSIZE }); + socket.on('history', function () { + socket.emit('history', history); + }); + socket.on('disconnect', function () { delete players[socket.name]; delete history[socket.name];