Answer the question
In order to leave comments, you need to log in
How to link an application to Bitrix via push and pull?
Hello. There is a built-in self-written application built into the boxed version of Bitrix. The goal is to connect all open pages with our application through the Bitrix event handler. Those. when pressing a button in the application, for all users who have this application open, display the conditional 'Hello World' in the console.
In short, register an event, subscribe, and learn how to catch events from Bitrix. Is it possible to do this?
Answer the question
In order to leave comments, you need to log in
Here's how it works for me:
A user subscribes to events associated with the $dctList['UUID'] object: We
send a notification to all users when an event occurs associated with the object with the identifier $list_uuid
\CPullWatch::Add($UserID, $dctList['UUID']);
\CPullWatch::AddToStack($list_uuid,
Array(
'module_id' => 'list',
'command' => 'exchange',
'params' => [
'provocative' => $dctData['head']['UID'],
'list_uuid'=> $list_uuid
]
)
);
BX.loadScript('/bitrix/js/pull/protobuf/protobuf.js', ()=>{
BX.loadScript('/bitrix/js/pull/protobuf/model.js', ()=>{
BX.loadScript('/bitrix/js/rest/client/rest.client.js', ()=>{
BX.loadScript('/bitrix/js/pull/client/pull.client.js',()=>{APP.bitrixreinit._pullinit()});
});
});
});
// подписываемся на события P&P
BX.addCustomEvent("onPullEvent", function(module_id,command,params) {
if (APP.getConfigParam('uid') == params.provocative) {
//if ('production' != APP.getConfigParam('mode')) console.log('собственное событие пропущено');
return;
}
if ('exchange' == command) {
APP.exchange({basis: 'pull', context: params});
}
});
BX.addCustomEvent("onPullStatus", function(status) {
if ('online' != APP.$store.state.status.push_and_pull
&& 'online' == status) {
// не онлайн сменился на онлайн
//let last_sync_time = APP.$store.state.db.sync.last.time.client || 0
//let now_time = Date.now()/1000
//if (now_time - last_sync_time < 30) {
//
//} else {
//
//}
APP.exchange({basis: 'reconnect'});
}
APP.$store.commit("updateStatus",{key:'push_and_pull',data:status})
});
BX.PULL.start();
Those. when pressing a button in the application, for all users who have this application open, display the conditional 'Hello World' in the console.It is possible , but it is better to implement it yourself through web sockets or a matrix.
There is a built-in self-written application
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question