🔥码云GVP开源项目 12k star Uniapp+ElementUI 功能强大 支持多语言、二开方便! 广告
# swoole_websocket_server->disconnect 主动向websocket客户端发送关闭帧并关闭该连接 ```php function swoole_websocket_server->disconnect(int $fd, int $code = 1000, string $reason = ""); ``` - $fd 客户端连接的ID,如果指定的$fd对应的TCP连接并非websocket客户端,将会发送失败 - $code 关闭连接的状态码,根据RFC6455,对于应用程序关闭连接状态码,取值范围为1000或4000-4999之间 - $reason 关闭连接的原因,utf-8格式字符串,字节长度不超过125 发送成功返回true,发送失败或状态码非法时返回false > swoole_websocket_server->disconnect在swoole-4.0.3以上版本可用