- fixed final "map update" sync request beforeUnload event

- fixed a bug where "multi character location tracking" is not working on different browser tabs, #446
- fixed a "map sync" bug with 2 open browser tabs with the same character active
This commit is contained in:
Mark Friedrich
2019-07-05 16:57:33 +02:00
parent 437fdf0db9
commit f4f30e0975
18 changed files with 380 additions and 224 deletions

View File

@@ -74,15 +74,25 @@ class AccessController extends Controller {
return $loginStatus;
}
/**
* broadcast MapModel to clients
* @see broadcastMapData()
* @param Pathfinder\MapModel $map
*/
protected function broadcastMap(Pathfinder\MapModel $map) : void {
$this->broadcastMapData($this->getFormattedMapData($map));
}
/**
* broadcast map data to clients
* -> send over TCP Socket
* @param Pathfinder\MapModel $map
* @throws \Exception
* @param array|null $mapData
*/
protected function broadcastMapData(Pathfinder\MapModel $map) : void {
$mapData = $this->getFormattedMapData($map);
$this->getF3()->webSocket()->write('mapUpdate', $mapData);
protected function broadcastMapData(?array $mapData) : void {
if(!empty($mapData)){
$this->getF3()->webSocket()->write('mapUpdate', $mapData);
}
}
/**
@@ -91,16 +101,27 @@ class AccessController extends Controller {
* @return array
* @throws \Exception
*/
protected function getFormattedMapData(Pathfinder\MapModel $map) : array {
$mapData = $map->getData();
return [
'config' => $mapData->mapData,
'data' => [
'systems' => $mapData->systems,
'connections' => $mapData->connections,
]
];
/**
* @param Pathfinder\MapModel $map
* @return array|null
*/
protected function getFormattedMapData(Pathfinder\MapModel $map) : ?array {
$data = null;
try{
$mapData = $map->getData();
$data = [
'config' => $mapData->mapData,
'data' => [
'systems' => $mapData->systems,
'connections' => $mapData->connections,
]
];
}catch(\Exception $e){
}
return $data;
}
}