• Модуль: pull
  • Путь к файлу: ~/bitrix/modules/pull/classes/general/pull_channel.php
  • Класс: CPullChannel
  • Вызов: CPullChannel::getOnlineUsers
static function getOnlineUsers(array $channels): array
{
	$arOnline = [];

	global $USER;
	$agentUserId = 0;
	if (is_object($USER) && $USER->GetId() > 0)
	{
		$agentUserId = $USER->GetId();
		$arOnline[$agentUserId] = $agentUserId;
	}

	if (BitrixPullConfig::isJsonRpcUsed())
	{
		$userList = array_map("intval", array_values($channels));
		$result = BitrixPullJsonRpcTransport::getUsersLastSeen($userList);
		if (!$result->isSuccess())
		{
			return [];
		}
		foreach ($result->getData() as $userId => $lastSeen)
		{
			if ($lastSeen == 0)
			{
				$arOnline[$userId] = $userId;
			}
		}
	}
	else
	{
		if (BitrixPullConfig::isProtobufUsed())
		{
			$channelsStatus = BitrixPullProtobufTransport::getOnlineChannels(array_keys($channels));
		}
		else
		{
			$channelsStatus = self::GetOnlineChannels(array_keys($channels));
		}

		foreach ($channelsStatus as $channelId => $onlineStatus)
		{
			$userId = $channels[$channelId];
			if ($userId == 0 || $agentUserId == $userId)
			{
				continue;
			}

			if ($onlineStatus)
			{
				$arOnline[$userId] = $userId;
			}
		}
	}


	return $arOnline;
}