企业🤖AI智能体构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
## websocket server ```php $ws = new swoole_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, welcome\n"); }); $ws->on('message', function ($ws, $frame) { echo "Message: {$frame->data}\n"; $ws->push($frame->fd, "server: {$frame->data}"); }); $ws->on('close', function ($ws, $fd) { echo "client-{$fd} is closed\n"; }); $ws->start();