WebSocket\Server->disconnect
主动向websocket
客户端发送关闭帧并关闭该连接
function 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
WebSocket\Server->disconnect
在4.0.3
以上版本可用