- WIP changed REQ/REP Socket config to PUSH/PULL Socket config

This commit is contained in:
Exodus4D
2017-01-19 21:11:08 +01:00
parent 90f94a559b
commit 37afac7c49
5 changed files with 68 additions and 22 deletions

View File

@@ -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

View File

@@ -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',

View File

@@ -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

View File

@@ -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);
};

View File

@@ -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);
};