public function onWorkerStart() {
// 監(jiān)聽一個 http 端口
$inner_http_worker = new Workerman( 'http://0.0.0.0:2288' );
// 當(dāng) http 客戶端發(fā)來數(shù)據(jù)時觸發(fā)
$inner_http_worker->onMessage = function( TcpConnection $http_connection ) {
$input = input();
$input['type_name'] = $input['type_name'] ?? '未知';
$input['type'] = $input['type'] ?? 'publish';
// 推送數(shù)據(jù)的 url 格式 type=publish&to=uid&content=xxxx
if ( !isset( $input['uuid'] ) ) return $http_connection->send( 'false' );
dump( $input );
return $http_connection->send( 'ok' );
};
// 執(zhí)行監(jiān)聽
$inner_http_worker->listen();
}
如上面 我用http請求這個ip:port 會重復(fù)打印兩次 請問是什么原因