diff options
author | Simon Rettberg | 2014-05-20 19:20:02 +0200 |
---|---|---|
committer | Simon Rettberg | 2014-05-20 19:20:02 +0200 |
commit | 4a8725b8dcac3bd0e7afe463968d281e4cf8df6c (patch) | |
tree | 8d1374edd2a1e74ed3a99813210ca84e999fb82c /inc/taskmanager.inc.php | |
parent | OO style modules (diff) | |
download | slx-admin-4a8725b8dcac3bd0e7afe463968d281e4cf8df6c.tar.gz slx-admin-4a8725b8dcac3bd0e7afe463968d281e4cf8df6c.tar.xz slx-admin-4a8725b8dcac3bd0e7afe463968d281e4cf8df6c.zip |
JS Stuff for Taskmanager interaction
More work on AD wizard
Diffstat (limited to 'inc/taskmanager.inc.php')
-rw-r--r-- | inc/taskmanager.inc.php | 29 |
1 files changed, 24 insertions, 5 deletions
diff --git a/inc/taskmanager.inc.php b/inc/taskmanager.inc.php index f2f337be..3353050f 100644 --- a/inc/taskmanager.inc.php +++ b/inc/taskmanager.inc.php @@ -12,21 +12,40 @@ class Taskmanager { if (self::$sock !== false) return; self::$sock = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP); - socket_set_option(self::$sock, SOL_SOCKET, SO_RCVTIMEO, array('sec' => 0, 'usec' => 100000)); - socket_set_option(self::$sock, SOL_SOCKET, SO_SNDTIMEO, array('sec' => 0, 'usec' => 100000)); + socket_set_option(self::$sock, SOL_SOCKET, SO_RCVTIMEO, array('sec' => 0, 'usec' => 300000)); + socket_set_option(self::$sock, SOL_SOCKET, SO_SNDTIMEO, array('sec' => 0, 'usec' => 200000)); socket_connect(self::$sock, '127.0.0.1', 9215); } - public static function submit($task, $data, $async) + public static function submit($task, $data, $async = false) { self::init(); $seq = (string)mt_rand(); - $data = json_encode($data); + if (empty($data)) { + $data = '{}'; + } else { + $data = json_encode($data); + } $message = "$seq, $task, $data"; $sent = socket_send(self::$sock, $message, strlen($message), 0); + if ($sent != strlen($message)) { + Message::addError('taskmanager-error'); + return false; + } if ($async) return true; $reply = self::readReply($seq); - if (!is_array($reply)) return false; + if ($reply === false) { + Message::addError('taskmanager-error'); + return false; + } + if (!is_array($reply)) { + Message::addError('taskmanager-format'); + return false; + } + if ($reply['statusCode'] === NO_SUCH_TASK) { + Message::addError('task-error', 'Ungültiger Task: ' . $task); + return false; + } return $reply; } |