示例#1
0
 public function onStartUserReplication(\Bitrix\Main\Event $event)
 {
     $parameters = $event->getParameters();
     $userId = $parameters[0];
     $domain = $parameters[2];
     $domainId = getNameByDomain($domain);
     if (!$domainId) {
         return;
     }
     $mapper = \Bitrix\Replica\Mapper::getInstance();
     $map = $mapper->getByPrimaryValue("b_user.ID", false, $userId);
     if (!$map) {
         return;
     }
     $guid = key($map);
     $event = array("operation" => "im_status_bind", "guid" => $guid);
     \Bitrix\Replica\Log\Client::getInstance()->write(array($domainId), $event);
     \Bitrix\Replica\Mapper::getInstance()->add("b_im_status.USER_ID", $userId, $domainId, $event["guid"]);
 }
示例#2
0
 /**
  * OnAfterRecentAdd event handler.
  * Sends "subscribe" message for b_im_message changes to peer database.
  *
  * @param \Bitrix\Main\Event $event Event object.
  *
  * @return void
  * @see \Bitrix\Im\Replica\StatusHandler::handleStatusRebindOperation
  */
 public function OnAfterRecentAdd(\Bitrix\Main\Event $event)
 {
     $userId = $event->getParameter('user_id');
     if (!$userId) {
         return;
     }
     $userGuid = \Bitrix\Replica\Client\User::getRemoteUserGuid($userId);
     if (!$userGuid) {
         return;
     }
     $mapper = \Bitrix\Replica\Mapper::getInstance();
     $map = $mapper->getByPrimaryValue("b_user.ID", false, $userId);
     if (!$map) {
         return;
     }
     $guid = key($map);
     $targetNode = current($map[$guid]);
     $domainId = getNameByDomain();
     $event = array("operation" => "im_status_rebind", "guid" => $userGuid . "@" . $targetNode, "nodes" => array($domainId), "ts" => time(), "ip" => \Bitrix\Main\Application::getInstance()->getContext()->getServer()->get('REMOTE_ADDR'));
     \Bitrix\Replica\Log\Client::getInstance()->write(array($targetNode), $event);
 }