Fixed weird things when window lost focus
This commit is contained in:
@@ -101,6 +101,9 @@ const socket = io({
|
|||||||
});
|
});
|
||||||
socket.on('connect', function () {
|
socket.on('connect', function () {
|
||||||
console.log('connected');
|
console.log('connected');
|
||||||
|
$(window).focus(function () {
|
||||||
|
socket.emit('history', current);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
socket.on('disconnect', function () {
|
socket.on('disconnect', function () {
|
||||||
console.log('disconnected');
|
console.log('disconnected');
|
||||||
@@ -114,6 +117,10 @@ socket.on('info', function (res) {
|
|||||||
drawGame()
|
drawGame()
|
||||||
});
|
});
|
||||||
|
|
||||||
|
socket.on('history', function (h) {
|
||||||
|
history = h;
|
||||||
|
});
|
||||||
|
|
||||||
socket.on('players', function (p) {
|
socket.on('players', function (p) {
|
||||||
players = p;
|
players = p;
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -160,6 +160,10 @@ io.on('connection', function (socket) {
|
|||||||
hsize:HSIZE
|
hsize:HSIZE
|
||||||
});
|
});
|
||||||
|
|
||||||
|
socket.on('history', function () {
|
||||||
|
socket.emit('history', history);
|
||||||
|
});
|
||||||
|
|
||||||
socket.on('disconnect', function () {
|
socket.on('disconnect', function () {
|
||||||
delete players[socket.name];
|
delete players[socket.name];
|
||||||
delete history[socket.name];
|
delete history[socket.name];
|
||||||
|
|||||||
Reference in New Issue
Block a user