代碼:
while($data = redis::lblpop('msg')){
$con = new AsyncTcpConnection('txt://127.0.0.1:123');
$con->send($data);
$con->onMessage = function(){
........
}
}
我這里好像不行, 異步服務(wù)端接受到的所有數(shù)據(jù)中只有一個數(shù)據(jù)是有效的 其他數(shù)據(jù)都被反轉(zhuǎn)義了!
假設(shè)$data = json_encode(array('a'=>1));
while發(fā)送數(shù)據(jù)三條到異步服務(wù)端,接受到的數(shù)據(jù):
{"a":1}
{\"a\":1}
{\"a\":1}
以上三條隨機出現(xiàn)