💎一站式轻松地调用各大LLM模型接口,支持GPT4、智谱、星火、月之暗面及文生图 广告
# open\_websocket\_close\_frame 启用websocket协议中关闭帧(opcode为0x08的帧)在onMessage回调中接收,默认为false。 开启后,可在WebSocketServer中的`onMessage`回调中接收到客户端或服务端发送的关闭帧,开发者可自行对其进行处理。 示例: ~~~ $server = new swoole_websocket_server("0.0.0.0", 9501); $server->set(array("open_websocket_close_frame" => true)); $server->on('open', function (swoole_websocket_server $server, $request) {}); $server->on('message', function (swoole_websocket_server $server, $frame) { if ($frame->opcode == 0x08) { echo "Close frame received: Code {$frame->code} Reason {$frame->reason}\n"; } else { echo "Message received: {$frame->data}\n"; } }); $server->on('close', function ($ser, $fd) {}); $server->start(); ~~~