- 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:
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user