Views: 5985
Last Modified: 15.09.2014

What Is This Module and What Is It For?

The Push and Pull module is used to display messages and notifications to website clients. Please refer to the relevant chapter of the course Bitrix24 Self-hosted For Advanced Users for more details.

Work Modes

The module Push & Pull works in two modes:

  • Continuous connection to a special server Queue Server;
  • In the server poll mode (60-20-10).

The first mode is recommended. It will give you the real interactivity, but you will have to set up the Queue Server or opt for a preset virtual machine.

The second mode is used when due to any reasons the first mode cannot be used. In this case, the module will access the server every 60 seconds and check if there are data available. If there are, the next hit will occur in 10 seconds. If there are no more data, the next hit will occur in 20 seconds and after that every 60 seconds; thus the effect of interactivity will be created.

API proper is divided into PHP and JS parts. Their operating principles are described below.

PHP Classes

To begin with, you have to connect a module:

if (!CModule::IncludeModule('pull'))
   return false;

and register dependency on the module PULL. Let us register the dependency handler:

RegisterModuleDependences("pull", "OnGetDependentModule", "your_module", "CYourModulePullSchema", "OnGetDependentModule" );

Then create own class. Class code

class CYourModulePullSchema
    public static function OnGetDependentModule()
        return Array(
            'MODULE_ID' => "your_module",
            'USE' => Array("PUBLIC_SECTION")

If your code is operated in the public part, the following should be indicated:


If the administrative section is needed in addition to the public part, the following should be indicated:


Before using own code, the connection shall be tested by using the methods of the CPullOptions class.

Further, API classes can be used in work:

Server part (PHP)
CPullStack Sending data.
CPullWatch Sending data to subscribed users.
CPushManager Sending a push notice.

JS Methods

Client part (JS)
Event BX.addCustomEvent A “trap” for Push & Pull commands.
BX.PULL.extendWatch Extended subscription.


A code for work with PHP methods described above:

BX.addCustomEvent("onPullEvent", function(module_id,command,params) {
    if (module_id == "test" && command == 'check')

We subscribe to the event “receipt of commands” (onPullEvent), and as a function we obtain module_id, command, and params which we indicated when sending a command from PHP. After that, we process our commands taking into account required logic.

An example of the component that works with the most complex method of subscriptions BX.PULL.extendWatch.

Courses developed by «Bitrix», Inc.