server:
創(chuàng)新互聯(lián)建站致力于成都網(wǎng)站制作、成都網(wǎng)站建設(shè)、外貿(mào)營(yíng)銷網(wǎng)站建設(shè),成都網(wǎng)站設(shè)計(jì),集團(tuán)網(wǎng)站建設(shè)等服務(wù)標(biāo)準(zhǔn)化,推過(guò)標(biāo)準(zhǔn)化降低中小企業(yè)的建站的成本,并持續(xù)提升建站的定制化服務(wù)水平進(jìn)行質(zhì)量交付,讓企業(yè)網(wǎng)站從市場(chǎng)競(jìng)爭(zhēng)中脫穎而出。 選擇創(chuàng)新互聯(lián)建站,就選擇了安全、穩(wěn)定、美觀的網(wǎng)站建設(shè)服務(wù)!
$ws=newswoole_websocket_server('0.0.0.0',9502);
$ws->on('open',function($ws,$request) {
var_dump($request->fd,$request->get,$request->server);
$ws->push($request->fd,"hello world\");
});
$ws->on('message',function($ws,$frame) {
echo"Message:{$frame->data}\";
$ws->push($frame->fd,"server:{$frame->data}");
});
$ws->on('close',function($ws,$fd) {
echo"client-{$fd} is closed\";
});
$ws->start();
client:
$cli=newswoole_http_client('127.0.0.1',9502);
$cli->on('message',function($_cli,$frame) {
var_dump($frame);
});
$cli->upgrade('/',function($cli) {
echo$cli->body;
$cli->push("hello world");
});