Views: 165
Last Modified: 10.03.2021

You can launch Push & Pull module for guests, but you need to assign a session to a specific guest. Unique numeric ID is required as well: without it, the same channel address cannot be issued to a guest and personalized commands cannot be sent to this guest. Starting from Push & Pull module version 15.5.1 such guest option is now available.

Developer must implement guest identification methods and assign an internal numeric ID for such guest. For example, guest ID is defined as 1. To avoid confusing authorized and non-authorized users, this ID can be passed into the Push & Pull module with a minus sign:

$guestId = -1;

CModule::IncludeModule('pull');
CPullStack::AddByUser($guestId, Array(
   'module_id' => 'test',
   'command' => 'check',
   'params' => Array(),
)); 

The method that defines the ID must be implemented and executed in prolog, before initializing Push & Pull module. To do it, register the following dependency:

RegisterModuleDependences("main", "OnProlog", "main", "", "", 2, "local/scripts/pull_hit.php");

You need to specify your own defining logic and constant PULL_USER_ID within the specified file, used for correctly generated channel for a guest. Each guest must have its own unique ID!

$guestId = -1; // your function must return this digit, determining an ID for a guest define('PULL_USER_ID', $guestId);

After that, your guests can get Push & Pull commands equally to the authorized users.

For debugging purposes, you can use the following JS commands:

Command JS
BX.PULL.getDebugInfo(); This command displays P&P server connection status;
BX.PULL.capturePullEvent(); This command logs all incoming commands for this user;



Courses developed by «Bitrix», Inc.