AnonSec Shell
Server IP : 85.193.89.191  /  Your IP : 3.144.224.210
Web Server : Apache
System : Linux 956367-cx40159.tmweb.ru 3.10.0-1160.105.1.el7.x86_64 #1 SMP Thu Dec 7 15:39:45 UTC 2023 x86_64
User : bitrix ( 600)
PHP Version : 8.1.27
Disable Function : NONE
MySQL : OFF  |  cURL : OFF  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : ON  |  Pkexec : ON
Directory :  /home/bitrix/www/bitrix/modules/bizproc/lib/integration/push/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ HOME ]     

Current File : /home/bitrix/www/bitrix/modules/bizproc/lib/integration/push/pushworker.php
<?php

namespace Bitrix\Bizproc\Integration\Push;

use Bitrix\Main;
use Bitrix\Main\Engine\CurrentUser;
use Bitrix\Main\Loader;
use Bitrix\Pull;

final class PushWorker
{
	private bool $canUse;
	private static $setJob = false;
	private static $queue = [];

	public function __construct()
	{
		$this->canUse = Loader::includeModule('pull');
	}

	public function subscribe(int $userId, string $command): void
	{
		if ($this->canUse)
		{
			\CPullWatch::Add($userId, $command);
		}
	}

	public function send(string $command, array $params, array $userIds = []): void
	{
		if (empty($userIds))
		{
			$userIds = [CurrentUser::get()?->getId() ?? 0];
		}

		if ($this->canUse)
		{
			Pull\Event::add(
				$userIds,
				[
					'module_id' => 'bizproc',
					'command' => $command,
					'params' => $params,
				]
			);
		}
	}

	public function sendLast(string $tag, string $command, array $params, array $userIds = [])
	{
		if ($this->canUse)
		{
			self::$queue[$tag] = [$command, $params, $userIds];
			$this->setBackgroundJob();
		}
	}

	private function setBackgroundJob()
	{
		if (!self::$setJob)
		{
			Main\Application::getInstance()->addBackgroundJob(
				[__CLASS__, 'doBackgroundJob'],
				[],
				Main\Application::JOB_PRIORITY_LOW - 10
			);
			self::$setJob = true;
		}
	}

	public static function doBackgroundJob()
	{
		$push = new self();

		foreach (self::$queue as [$command, $params, $userIds])
		{
			$push->send($command, $params, $userIds);
		}
	}
}

Anon7 - 2022
AnonSec Team