代碼:
while($data = redis::lblpop('msg')){
$con = new AsyncTcpConnection('txt://127.0.0.1:123');
$con->send($data);
$con->onMessage = function(){
........
}
}
假設(shè)$data = json_encode(array('a'=>1));
while發(fā)送數(shù)據(jù)三條到異步服務端,接受到的數(shù)據(jù):
{"a":1}
{\"a\":1}
{\"a\":1}
以上三條隨機出現(xiàn)