From: paulr Date: Mon, 19 Sep 2011 18:35:29 +0000 (+1000) Subject: configs and comms X-Git-Url: http://git.pjr.cc/?a=commitdiff_plain;h=90e37664d8296ebb5f3aae443b44b09f95826e90;p=CBFWR.git configs and comms --- diff --git a/bin/cbfwrd.php b/bin/cbfwrd.php index b5a91b3..3b29870 100644 --- a/bin/cbfwrd.php +++ b/bin/cbfwrd.php @@ -32,6 +32,10 @@ while($cont) { $comms->putConfig($config->getConfig()); + $msg = $comms->waitForMessage(); + + //echo "Got message: $msg\n"; + $cont = false; } ?> \ No newline at end of file diff --git a/libcbfwr/comms.php b/libcbfwr/comms.php index b1195c9..db0215e 100644 --- a/libcbfwr/comms.php +++ b/libcbfwr/comms.php @@ -37,11 +37,18 @@ class Comms { function waitForMessage() { + global $MESSAGE_KEY, $LOCKING_KEY, $STORE_KEY; + $queue = msg_get_queue($MESSAGE_KEY); + msg_receive($queue, 0, $msgtype, 1024, $msg); + return $msg; } - function sendMessage() + function sendMessage($msg) { + global $MESSAGE_KEY, $LOCKING_KEY, $STORE_KEY; + $queue = msg_get_queue($MESSAGE_KEY); + msg_send($queue, 1, $msg); } diff --git a/unittests/readconfigfromshm.php b/unittests/readconfigfromshm.php index f05849b..1c1247c 100644 --- a/unittests/readconfigfromshm.php +++ b/unittests/readconfigfromshm.php @@ -23,4 +23,6 @@ $conf = $comms->getConfig(); print_r($conf); +$comms->sendMessage("hi there"); + ?> \ No newline at end of file