External Webserver as Hub Server
JeffHD opened this issue ยท 2 comments
Feature Description: Adding the ability to use the external webserver as hub for multiple server.
Additional context: I know that it is asked a lot, but since the external web server already has its own tile folder and world json for each world, why not use it as a central map for several servers. The prerequisite is that every world has a unique name. Then nothing should interfere.
The last thing I heard about this was this #1495
According to this it will go on the list but i never heard something new about it
Thank you for your feature request. Due to the volume of feature requests we receive we have relocated all of our features requests to a single issue #3461.
Okay i looked into it and found a solution.
Make a backup just in case!
in the web folder edit the index.html and change
<script type="text/javascript" src="standalone/config.js?_=3.1-457"></script>
to
<script type="text/javascript" src="standalone/config_hub.js?_=3.1-457"></script>
than in the web/standalone folder copy the config.js to config_hub.js and change
configuration: 'standalone/dynmap_configjson?_={timestamp}',
to
configuration: 'standalone/dynmap_config_hub.json?_={timestamp}',
and add the line
players: 'standalone/dynmap_players.php?_={timestamp}',
next copy the dynmap_config.json with all worlds set to dynmap_config_hub.json
all settings now go into this file.
now create a new file named dynmap_players.php with following content:
<?php
//get all Files
$json1 = file_get_contents('https://map.hellpoint-gaming.de/dynmapneu/standalone/dynmap_world_1.json');
$obj1 = json_decode($json1);
$json2 = file_get_contents('https://map.hellpoint-gaming.de/dynmapneu/standalone/dynmap_world_2.json');
$obj2 = json_decode($json2);
$json3 = file_get_contents('https://map.hellpoint-gaming.de/dynmapneu/standalone/dynmap_world_3.json');
$obj3 = json_decode($json3);
//get Playercount
$int1 = $obj1->currentcount;
$int2 = $obj2->currentcount;
$int3 = $obj3->currentcount;
$currentcount = $int1+$int2+$int3;
//get Playerpositions
$array1 = $obj1->players;
$array2 = $obj2->players;
$array3 = $obj3->players;
$players = array_merge ($array1, $array2, $array3);
//print json
$data = array('currentcount' => $currentcount, 'players' => $players);
header('Content-type: text/javascript');
echo json_encode($data);
?>
edit the dynmap_world_1-3.json to the filenames of the world json files.
add or remove if more or less worlds are required.
for adding worlds just add $json4,$obj4,$int4 and so on for each world.
now in the web/js folder open the map.js file and remove at line 666
if(me.options.confighash != update.confighash) {
window.location = me.getLink();
return;
}
at line 667 change
me.playerfield.text(me.options['msg-players'] + " [" + update.currentcount + "/" + me.options.maxcount + "]");
to
$.getJSON(me.formatUrl('players', {}), function(update) {
me.playerfield.text(me.options['msg-players'] + " [" + update.currentcount + "/" + me.options.maxcount + "]");
})
and at line 684 add before the
var newplayers = {};
this line:
$.getJSON(me.formatUrl('players', {}), function(update) {
and at line 706 add after the
}
-> })
I havent looked into messages since i dont use the system so i cant say if these will work.
I know its not the perfect solution but it works like a normal dynmap for me and runs fine with 4 server behind it.
Its just important that all worlds have unique names.
Hope it helps someone who want that too