• Модуль: im
  • Путь к файлу: ~/bitrix/modules/im/lib/controller/call.php
  • Класс: BitrixImControllerCall
  • Вызов: Call::hangupAction
public function hangupAction($callId, $callInstanceId, $retransmit = true)
{
	$currentUserId = $this->getCurrentUser()->getId();
	$call = Registry::getCallWithId($callId);
	if (!$call)
	{
		$this->addError(new Error(Loc::getMessage("IM_REST_CALL_ERROR_CALL_NOT_FOUND"), "call_not_found"));
		return null;
	}

	if(!$this->checkCallAccess($call, $currentUserId))
		return null;

	$lockName = static::getLockNameWithCallId($callId);
	if (!Application::getConnection()->lock($lockName, static::LOCK_TTL))
	{
		$this->addError(new Error("Could not get exclusive lock", "could_not_lock"));
		return null;
	}

	$callUser = $call->getUser($currentUserId);
	if($callUser)
	{
		$callUser->updateState(CallUser::STATE_IDLE);
		$callUser->updateLastSeen(new DateTime());
	}

	if(!$call->hasActiveUsers())
	{
		$call->finish();
	}

	Application::getConnection()->unlock($lockName);

	if($retransmit)
	{
		$userIds = $call->getUsers();
		$call->getSignaling()->sendHangup($currentUserId, $userIds, $callInstanceId);
	}
}