• Модуль: voximplant
  • Путь к файлу: ~/bitrix/modules/voximplant/lib/routing/queue.php
  • Класс: BitrixVoximplantRoutingQueue
  • Вызов: Queue::getNextAction
public function getNextAction(Call $call, array $request = [])
{
	if(!$this->queue)
	{
		return new Action(Command::VOICEMAIL, ['REASON' => 'Queue ' . $this->queueId . 'is not found']);
	}

	[$users, $busyUsers] = $this->getUsersToInvite($this->queue, $call->getQueueHistory());

	if(!empty($users))
	{
		$call->addToQueueHistory(array_keys($users));
		$this->queue->touchUser(array_keys($users)[0]);

		return new Action(Command::INVITE, [
			'TYPE_CONNECT' => 'queue',
			'USERS' => array_values($users),
			'QUEUE' => $this->queue->toArray()
		]);
	}

	// could not find users to invite
	if ($this->queue->getNoAnswerRule() == CVoxImplantIncoming::RULE_QUEUE && (!empty($call->getQueueHistory()) || !empty($busyUsers)))
	{
		$call->clearQueueHistory();

		if (!empty($busyUsers))
		{
			// enqueue call and wait for free user
			return $this->enqueue($call);
		}
		else
		{
			// queue history was not empty, move to the head of the queue
			return $this->getNextAction($call);
		}
	}
	else
	{
		return $this->leaveQueue($call);
	}
}