@vcherepko

Почему не работает «ловушка» для команд Push & Pull Битрикс?

Добрый день.
Не могу разобраться почему не срабатывает ловушка для push уведомлений.
init.php:
AddEventHandler("pull", "OnGetDependentModule", ["PullService", 'getPullModule']);
class PullService
{
  public static function getPullModule()
  {
    return [
      'MODULE_ID' => 'test',
      'USE' => ["PUBLIC_SECTION"],
    ];
  }
}

Модуль Push & Pull:
6582ea89e35c9619560288.png
Реализация через компонент
$APPLICATION->IncludeComponent("alternativa.prod:push","");
структура компонента:
class.php
/**
 * Обработка ajax события push
 */
public function pushAction()
{
    try {
        if (!Loader::includeModule('pull')) 
            return false;
        if (!CPullOptions::GetNginxStatus()) 
            return false;

        $userId = \Bitrix\Main\Engine\CurrentUser::get()->getId();
        CPullWatch::Add($userId, 'PULL_TEST');
        CPullWatch::AddToStack('PULL_TEST',
          Array(
            'module_id' => 'test',
            'command' => 'check',
            'params' => Array("TIME" => time())
          )
        ); 

        return [
            "nginx" => CPullOptions::GetNginxStatus(),
            "push"  => CPullOptions::GetPushStatus(),
            "result" => true
        ];

    } catch (Exceptions\EmptyEmail $e) {}
}

script.js
class JSPush {  
  constructor() {

    BX.addCustomEvent("onPullEvent", function(module_id,command,params) {
      console.log( 'Работаю!' )
    });

    BX.addCustomEvent("onPullStatus", function(status) {
      console.log( status )
      if (status == "online") {
        BX.PULL.getDebugInfo()
      }
    });
    BX.PULL.start();
    BX.PULL.extendWatch('PULL_TEST');

  }

  push() {
    BX.ajax.runComponentAction("alternativa.prod:push", "push", { 
      mode: "class",
      data: {},
    }).then(function (response) {
      console.log( response )
    });
  }
}


лог "onPullStatus" и "BX.PULL.getDebugInfo()"
connect
online

pull.client.js?168829948081012:2114 
========= PULL DEBUG ===========
UserId: 1 
Browser online: Y
Connect: Y
Server type: local
WebSocket supported: Y
WebSocket connected: Y
WebSocket mode: protobuf
Try connect: N
Try number: 0

Path: ---------hide----------
ChannelID: 594b05bccdbb382275899f2ff2449662:2ca0f195727cf2cafa2ec210f65b8063.5ff3e1ded2df454e2ae88bfbf5984b6668fe7231
ChannelDie: 2023-12-20T21:26:44+03:00
ChannelDieShared: 2023-12-20T21:01:34+03:00

Last message: -
Session history: {}
Watch tags: {"PULL_TEST":true}
================================


И с аяксом и без "ловышка" не срабатывает...
Надеюсь на помощь, спасибо.
  • Вопрос задан
  • 105 просмотров
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы