diff --git a/app/environment.ini b/app/environment.ini index 27c6ace5..d9842588 100644 --- a/app/environment.ini +++ b/app/environment.ini @@ -46,7 +46,7 @@ SMTP_FROM = pathfinder@localhost.com SMTP_ERROR = pathfinder@localhost.com ; TCP Socket configuration (optional) (advanced) -;SOCKET_HOST = localhost +;SOCKET_HOST = 127.0.0.1 ;SOCKET_PORT = 5555 @@ -90,5 +90,5 @@ SMTP_FROM = registration@pathfinder-w.space SMTP_ERROR = admin@pathfinder-w.space ; TCP Socket configuration (optional) (advanced) -;SOCKET_HOST = localhost +;SOCKET_HOST = 127.0.0.1 ;SOCKET_PORT = 5555 \ No newline at end of file diff --git a/app/main/controller/setup.php b/app/main/controller/setup.php index b6c8e989..27069e55 100644 --- a/app/main/controller/setup.php +++ b/app/main/controller/setup.php @@ -940,7 +940,7 @@ class Setup extends Controller { $socketInformation = [ 'tcpSocket' => [ 'label' => 'Socket (intern) [TCP]', - 'online' => (self::checkTcpSocket($ttl) == '1'), + 'online' => (self::checkTcpSocket($ttl) == 'OK'), 'data' => [ [ 'label' => 'HOST', diff --git a/app/main/lib/socket.php b/app/main/lib/socket.php index 11c61b4f..65000a4e 100644 --- a/app/main/lib/socket.php +++ b/app/main/lib/socket.php @@ -81,6 +81,7 @@ class Socket { /** * init new socket */ + /* public function initSocket(){ if(self::checkRequirements()){ $context = new \ZMQContext(); @@ -88,6 +89,42 @@ class Socket { // The linger value of the socket. Specifies how long the socket blocks trying flush messages after it has been closed $this->socket->setSockOpt(\ZMQ::SOCKOPT_LINGER, 0); } + } */ + + /** + * init new socket + */ + public function initSocket(){ + if(self::checkRequirements()){ + $context = new \ZMQContext(); + $this->socket = $context->getSocket(\ZMQ::SOCKET_PUSH); + // The linger value of the socket. Specifies how long the socket blocks trying flush messages after it has been closed + //$this->socket->setSockOpt(\ZMQ::SOCKOPT_LINGER, 0); + } + } + + public function sendData($task, $load = ''){ + $response = false; + + $this->initSocket(); + + if( !$this->socket ){ + // Socket not active (e.g. URI missing) + return $response; + } + + // add task, and wrap data + $send = [ + 'task' => $task, + 'load' => $load + ]; + + $this->socket->connect($this->socketUri); + $this->socket->send(json_encode($send)); + + $response = 'OK'; + + return $response; } /** @@ -97,6 +134,7 @@ class Socket { * @param $load * @return bool|string */ + /* public function sendData($task, $load = ''){ $response = false; @@ -138,11 +176,11 @@ class Socket { $startTime = microtime(true); // infinite loop until we get a proper answer while(true){ - /* Amount of events retrieved */ + // Amount of events retrieved $events = 0; try{ - /* Poll until there is something to do */ + // Poll until there is something to do $events = $poller->poll($readable, $writable, $this->ttl); $errors = $poller->getLastErrors(); @@ -188,7 +226,7 @@ class Socket { $this->socket->disconnect($this->socketUri); return $response; - } + }*/ /** * check whether this installation fulfills all requirements diff --git a/js/app/mappage.js b/js/app/mappage.js index caab9646..881fe489 100644 --- a/js/app/mappage.js +++ b/js/app/mappage.js @@ -180,17 +180,20 @@ define([ /** * init (schedule) next MapUpdate Ping */ - let initMapUpdatePing = () => { + let initMapUpdatePing = (forceUpdateMapData) => { // get the current update delay (this can change if a user is inactive) let delay = Util.getCurrentTriggerDelay( logKeyServerMapData, 0 ); - updateTimeouts.mapUpdate = setTimeout(() => { - triggerMapUpdatePing(); - }, delay); + updateTimeouts.mapUpdate = setTimeout((forceUpdateMapData) => { + triggerMapUpdatePing(forceUpdateMapData); + }, delay, forceUpdateMapData); }; // ping for main map update ======================================================== - let triggerMapUpdatePing = () => { + /** + * @param forceUpdateMapData // force request to be send + */ + let triggerMapUpdatePing = (forceUpdateMapData) => { // check each interval if map module is still available let check = $('#' + mapModule.attr('id')).length; @@ -210,6 +213,7 @@ define([ // -> if "syncType" === "ajax" -> send always // -> if "syncType" === "webSocket" -> send initial AND on map changes if( + forceUpdateMapData || Util.getSyncType() === 'ajax' || ( Util.getSyncType() === 'webSocket' && @@ -256,7 +260,7 @@ define([ let mapUpdateDelay = Util.getCurrentTriggerDelay( logKeyServerMapData, 0 ); // init new trigger - initMapUpdatePing(); + initMapUpdatePing(false); // initial start for the userUpdate trigger // this should only be called at the first time! @@ -271,7 +275,7 @@ define([ }).fail(handleAjaxErrorResponse); }else{ // skip this mapUpdate trigger and init next one - initMapUpdatePing(); + initMapUpdatePing(false); } }; @@ -363,7 +367,7 @@ define([ }; // initial start of the map update function - triggerMapUpdatePing(); + triggerMapUpdatePing(true); }; diff --git a/public/js/v1.2.0/app/mappage.js b/public/js/v1.2.0/app/mappage.js index caab9646..881fe489 100644 --- a/public/js/v1.2.0/app/mappage.js +++ b/public/js/v1.2.0/app/mappage.js @@ -180,17 +180,20 @@ define([ /** * init (schedule) next MapUpdate Ping */ - let initMapUpdatePing = () => { + let initMapUpdatePing = (forceUpdateMapData) => { // get the current update delay (this can change if a user is inactive) let delay = Util.getCurrentTriggerDelay( logKeyServerMapData, 0 ); - updateTimeouts.mapUpdate = setTimeout(() => { - triggerMapUpdatePing(); - }, delay); + updateTimeouts.mapUpdate = setTimeout((forceUpdateMapData) => { + triggerMapUpdatePing(forceUpdateMapData); + }, delay, forceUpdateMapData); }; // ping for main map update ======================================================== - let triggerMapUpdatePing = () => { + /** + * @param forceUpdateMapData // force request to be send + */ + let triggerMapUpdatePing = (forceUpdateMapData) => { // check each interval if map module is still available let check = $('#' + mapModule.attr('id')).length; @@ -210,6 +213,7 @@ define([ // -> if "syncType" === "ajax" -> send always // -> if "syncType" === "webSocket" -> send initial AND on map changes if( + forceUpdateMapData || Util.getSyncType() === 'ajax' || ( Util.getSyncType() === 'webSocket' && @@ -256,7 +260,7 @@ define([ let mapUpdateDelay = Util.getCurrentTriggerDelay( logKeyServerMapData, 0 ); // init new trigger - initMapUpdatePing(); + initMapUpdatePing(false); // initial start for the userUpdate trigger // this should only be called at the first time! @@ -271,7 +275,7 @@ define([ }).fail(handleAjaxErrorResponse); }else{ // skip this mapUpdate trigger and init next one - initMapUpdatePing(); + initMapUpdatePing(false); } }; @@ -363,7 +367,7 @@ define([ }; // initial start of the map update function - triggerMapUpdatePing(); + triggerMapUpdatePing(true); };