From 49d66436d1387bcfc14a6499e0f7621a8e4f84b0 Mon Sep 17 00:00:00 2001 From: libccy Date: Tue, 26 Apr 2016 10:34:31 +0800 Subject: [PATCH] phantom --- game/game.js | 9 +++++---- game/phantom.js | 36 ++++++++++++++++++------------------ 2 files changed, 23 insertions(+), 22 deletions(-) diff --git a/game/game.js b/game/game.js index 849573df5..bdb03f3fc 100755 --- a/game/game.js +++ b/game/game.js @@ -27,8 +27,9 @@ break; } } - if(window.location.href.indexOf('index.html?server')!=-1){ - window.isNonameServer=true; + var index=window.location.href.indexOf('index.html?server='); + if(index!=-1){ + window.isNonameServer=window.location.href.slice(index+18); window.indexedDB=null; } }()); @@ -12513,7 +12514,7 @@ },true); if(window.isNonameServer){ - var cfg='pagecfg'+lib.config.pageId; + var cfg='pagecfg'+window.isNonameServer; if(lib.config[cfg]){ lib.configOL=lib.config[cfg][0]; game.send('server','server',lib.config[cfg].slice(1)); @@ -16034,7 +16035,7 @@ } if(window.isNonameServer){ lib.configOL.gameStarted=false; - game.saveConfig('pagecfg'+lib.config.pageId,[lib.configOL,game.roomId,_status.onlinenickname,_status.onlineavatar]); + game.saveConfig('pagecfg'+window.isNonameServer,[lib.configOL,game.roomId,_status.onlinenickname,_status.onlineavatar]); game.reload(); } }, diff --git a/game/phantom.js b/game/phantom.js index 4224c06c1..314afa71d 100644 --- a/game/phantom.js +++ b/game/phantom.js @@ -1,38 +1,38 @@ +var reload=function(){ + if(!lib.node||!lib.node.clients||!lib.node.clients.length){ + game.reload(); + } +}; + var page1 = require('webpage').create(); page1.settings.userAgent = 'SpecialAgent'; -page1.open('http://localhost/index.html?server=true', function(status) { +page1.open('http://localhost/index.html?server=1', function(status) { if(status !== 'success') { console.log('Unable to access network'); } - else{ - page.evaluate(function(){ - game.saveConfig('pageId',1); - }); - } + setInterval(function(){ + page1.evaluate(reload); + },3600000); }); var page2 = require('webpage').create(); page2.settings.userAgent = 'SpecialAgent'; -page2.open('http://localhost/index.html?server=true', function(status) { +page2.open('http://localhost/index.html?server=2', function(status) { if(status !== 'success') { console.log('Unable to access network'); } - else{ - page.evaluate(function(){ - game.saveConfig('pageId',2); - }); - } + setInterval(function(){ + page2.evaluate(reload); + },3600000); }); var page3 = require('webpage').create(); page3.settings.userAgent = 'SpecialAgent'; -page3.open('http://localhost/index.html?server=true', function(status) { +page3.open('http://localhost/index.html?server=3', function(status) { if(status !== 'success') { console.log('Unable to access network'); } - else{ - page.evaluate(function(){ - game.saveConfig('pageId',3); - }); - } + setInterval(function(){ + page3.evaluate(reload); + },3600000); });