- Модуль: pull
- Путь к файлу: ~/bitrix/modules/pull/classes/general/pull_channel.php
- Класс: CPullChannel
- Вызов: CPullChannel::Send
static function Send($channelId, $message, $options = array())
{
$result_start = '{"infos": ['; $result_end = ']}';
if (is_array($channelId) && CPullOptions::GetQueueServerVersion() == 1 && !CPullOptions::IsServerShared())
{
$results = Array();
foreach ($channelId as $channel)
{
$results[] = self::SendCommand($channel, $message, $options);
}
$result = json_decode($result_start.implode(',', $results).$result_end);
}
else if (is_array($channelId))
{
$commandPerHit = CPullOptions::GetCommandPerHit();
if (count($channelId) > $commandPerHit)
{
$arGroup = Array();
$i = 0;
foreach($channelId as $channel)
{
if (!isset($arGroup[$i]))
{
$arGroup[$i] = [];
}
if (count($arGroup[$i]) == $commandPerHit)
{
$i++;
}
$arGroup[$i][] = $channel;
}
$results = Array();
foreach($arGroup as $channels)
{
$result = self::SendCommand($channels, $message, $options);
$subresult = json_decode($result);
if (is_array($subresult->infos))
{
$results = array_merge($results, $subresult->infos);
}
}
$result = json_decode('{"infos":'.json_encode($results).'}');
}
else
{
$result = self::SendCommand($channelId, $message, $options);
$result = json_decode($result);
}
}
else
{
$result = self::SendCommand($channelId, $message, $options);
if($result === false)
{
return $result;
}
$result = json_decode($result_start.$result.$result_end);
}
return $result;
}