From 90e37664d8296ebb5f3aae443b44b09f95826e90 Mon Sep 17 00:00:00 2001 From: paulr Date: Tue, 20 Sep 2011 04:35:29 +1000 Subject: [PATCH] configs and comms --- bin/cbfwrd.php | 4 ++++ libcbfwr/comms.php | 9 ++++++++- unittests/readconfigfromshm.php | 2 ++ 3 files changed, 14 insertions(+), 1 deletions(-) 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 -- 1.7.0.4