Gateway::sendToGroup问题请教

wenruns

问题描述

Gateway::sendToGroup第一个参数$group指的是什么?我试过传入client_id数组和uid数组都没用,

        if (count((array)$to) > 1) {
            $to = array_unique(array_filter($to));
            if (!empty($exclude_client_id) && $toType == 'uid') { // 排除目标:分组推送
                // 如果是uid则将uid转换为绑定的client_id
                $exclude_ids = [];
                foreach ((array)$exclude_client_id as $item) {
                    $exclude_ids = array_merge($exclude_ids, Gateway::getClientIdByUid($item));
                }
                $exclude_client_id = $exclude_ids;
            }
            if ($toType == 'uid') {
                $clientIds = [];
                foreach ((array)$to as $uid) {
                    $cid = Gateway::getClientIdByUid($uid);
                    file_put_contents(__DIR__ . '/日志.log', $uid . '::' . json_encode($cid) . "\r\n", FILE_APPEND);
                    $clientIds = array_merge($clientIds, $cid);
                }
            } else {
                $clientIds = $to;
            }
            file_put_contents(__DIR__ . '/日志.log', json_encode([
                    'to' => $to,
                    'clients' => $clientIds,
                    'exclude' => $exclude_client_id,
                    'msg' => $message,
                ]) . "\r\n", FILE_APPEND);
            return Gateway::sendToGroup((array)$clientIds, $message, $exclude_client_id);
        }
237 2 0
2个回答

walkor

要先joinGroup,参考文档 https://www.workerman.net/doc/gateway-worker/join-group.html
group是一个群体的标识,例如QQ群里的群ID

  • 暂无评论
wenruns

后来才发现,这尼玛只能传 Gateway::joinGroup($clientId, '分组名称');中的分组名称或者分组名称数组,不能直接传client_id数组

  • 暂无评论
🔝