<?php
// get out master library for gaasd daemon
-require_once("../lib/lib.php");
+require_once("../lib/gaasdLib.php");
// first we want to fork into the background like all good daemons should
//$pid = pcntl_fork();
} else if(!$forked) {
// I am the child, i process the request
// all the shit down below goes in here
+ $recvd = "";
+ $continue = true;
+ while($continue) {
+ $size = socket_recv($data_socket, $recvd_a, 1024, 0);
+ $recvd .= $recvd_a;
+ if(preg_match("/.*\:EOD$/", $recvd)) {
+ // we have a full string... break out
+ $continue = false;
+ break;
+ }
+ }
+
+ $xps = explode(":", $recvd);
+ $component = unserialize(base64_decode($xps[1]));
+ $msg_type = $component["type"];
+ $msg = $component["data"];
+
+ $data_returned = processMessage($msg_type, $msg);
+
+ $d_comp["type"] = $msg_type;
+ $d_comp["data"] = $data_returned;
+
+ $realdata_returning = "AS:".base64_encode(serialize($d_comp)).":EOD";
+
+ socket_send($data_socket, $realdata_returning, strlen($realdata_returning), 0);
+ socket_close($data_socket);
}
}
}
+function processMessage($msg_type, $msg)
+{
+ global $MESSAGES;
+
+ $function = $MESSAGES[$msg_type]."_server";
+
+ if(function_exists($function)) {
+ return $function($msg);
+ } else {
+ error_log("Call to undefined function! $function\n");
+ return false;
+ }
+
+}
+
+
?>
\ No newline at end of file