class Events
{
static $receiver = null;
public static function onWorkerStart($businessWorker)
{
$reboot = Robot::getInstance();
}
同時在start_businesswork.php有如下測試代碼
$inner_text_worker = new Worker('Text://0.0.0.0:5678');
$inner_text_worker->onMessage = function ($connection, $buffer) {
Robot::getInstance()
};
$inner_text_worker->listen();
Robot主要代碼
protected function __construct()
{
echo "創(chuàng)建robot類\n";
}
public static function getInstance()
{
static $_instance = null;
if ($_instance === null) {
$_instance = new Robot();
}
return $_instance;
}
測試發(fā)現(xiàn),Robot類創(chuàng)建了兩次,說明數(shù)據(jù)不能在多個Event中共享?