報(bào)錯(cuò)是這樣的
2019-07-03 16:20:53 pid:25979 Worker process terminated with ERROR: E_COMPILE_ERROR "Declaration of Workerman\Events\React\Base::cancelTimer(React\EventLoop\TimerInterface $timer) must be compatible with React\EventLoop\LoopInterface::cancelTimer(React\EventLoop\Timer\TimerInterface $timer) in /www/wwwroot/ws.hq.dyhjw.com2/vendor/workerman/workerman/Events/React/Base.php on line 22"
2019-07-03 16:20:53 pid:27591 worker exit with status 65280
服務(wù)端代碼如下:
// 當(dāng)$sender_io啟動(dòng)后監(jiān)聽一個(gè)http端口,通過這個(gè)端口可以給任意uid或者所有uid推送數(shù)據(jù)
$sender_io->on('workerStart', function(){
global $factory;
$loop = Worker::getEventLoop();
$factory = new Factory($loop);
$factory->createClient('localhost:6379')->then(function (Client $client) {
$client->auth('123456');
$client->subscribe('quotes')->then(function () {
echo 'Now subscribed to channel ';
});
$client->on('message', function ($event_name, $message) {
global $sender_io, $uidConnectionMap;
if ($uidConnectionMap) {
$value = json_decode($message, true);
$data = ;
// 在編碼數(shù)組里,就進(jìn)行發(fā)送
$code = $data;
if($code){
//$sender_io->emit('data', $data);
$sender = $sender_io->to($code);
if($sender){
$sender->emit('data', $data);
}
}
}
});
});
});