Channel分布式通讯分组发送文档代码有误

liwd

问题描述

这里写描述
Channel分布式通讯组件的分组发送的文档例子中关闭连接回调函数中第二个if逻辑写错位置了

程序代码或配置

官方文档:
$worker->onClose = function(TcpConnection $con){
        global $group_con_map;
        // 遍历连接加入的所有群组,从group_con_map删除对应的数据
        if (isset($con->group_id)) {
            foreach ($con->group_id as $group_id) {
                unset($group_con_map[$group_id][$con->id]);
            }
            if (empty($group_con_map[$group_id])) {
                unset($group_con_map[$group_id]);
            }
        }
    };

修改:
$worker->onClose = function(TcpConnection $con){
    global $group_con_map;
    // 遍历连接加入的所有群组,从group_con_map删除对应的数据
    if (isset($con->group_id)) {
        foreach ($con->group_id as $group_id) {
            unset($group_con_map[$group_id][$con->id]);
            if (empty($group_con_map[$group_id])) {
                unset($group_con_map[$group_id]);
            }
        }
    }
};

操作系统环境及workerman/webman等具体版本

这里写具体的系统环境相关信息
workerman官网最新文档

359 1 0
1个回答

walkor

已修复,感谢反馈

  • 暂无评论
🔝