• Модуль: xmpp
  • Путь к файлу: ~/bitrix/modules/xmpp/classes/server.php
  • Класс: CXMPPServer
  • Вызов: CXMPPServer::__RefineClientsList
private function __RefineClientsList()
{
	$arClientsKeys = array_keys($this->arClients);
	foreach ($arClientsKeys as $id)
	{
		if ($this->arClients[$id]->IsConnected() && !feof($this->arSockets[$id + $this->socketsClientsStartIndex]))
			continue;

		if ($this->arClients[$id]->IsConnected())
		{
			$this->WriteToLog("Client disconnected from REFINE (".$id.")", 5);
			$this->arClients[$id]->Disconnect();
		}

		$clientDomain = $this->arClients[$id]->GetClientDomain();
		$clientJId = $this->arClients[$id]->GetJId();
		$clientJIdWithResource = $this->arClients[$id]->GetJIdWithResource();

		if (is_array($this->arClientsIndex[$clientDomain][$clientJId]))
		{
			if (($i = array_search($id, $this->arClientsIndex[$clientDomain][$clientJId])) !== false)
				unset($this->arClientsIndex[$clientDomain][$clientJId][$i]);
		}

		if ($this->arClients[$id]->IsAuthenticated()
			 && (!array_key_exists($clientJId, $this->arClientsIndex[$clientDomain])
				  || count($this->arClientsIndex[$clientDomain][$clientJId]) <= 0))
		{
			foreach ($this->arClientsIndex[$clientDomain] as $jid1 => $arId1)
			{
				foreach ($arId1 as $id1)
				{
					if (($id1 != $id) && $this->arClients[$id1]->IsAuthenticated())
					{
						$this->Send(
							$jid1,
							array(
								"presence" => array(
									"." => array(
										"type" => "unavailable",
										"from" => $clientJIdWithResource,
										"to" => CXMPPUtility::GetJIdWithResource($jid1, $clientDomain),
									),
								),
							),
							$clientDomain
						);
					}
				}
			}
		}

		unset($this->arClients[$id]);
		unset($this->arSockets[$id + $this->socketsClientsStartIndex]);

		$this->WriteToLog("Client disconnected (".$id.")", 5);
	}
}