You are here

function BackgroundProcess::sendMessage in Background Process 7

Same name and namespace in other branches
  1. 8 background_process.class.php \BackgroundProcess::sendMessage()
  2. 7.2 background_process.inc \BackgroundProcess::sendMessage()
2 calls to BackgroundProcess::sendMessage()
BackgroundProcess::dispatch in ./BackgroundProcess.class.php
BackgroundProcess::lock in ./BackgroundProcess.class.php

File

./BackgroundProcess.class.php, line 209
Class for handling background processes.

Class

BackgroundProcess
BackgroundProcess class.

Code

function sendMessage($action) {
  if (module_exists('nodejs')) {
    if (!isset($this->progress_object)) {
      if ($progress = progress_get_progress($this->handle)) {
        $this->progress_object = $progress;
        $this->progress = $progress->progress;
        $this->progress_message = $progress->message;
      }
      else {
        $this->progress = 0;
        $this->progress_message = '';
      }
    }
    $object = clone $this;
    $message = (object) array(
      'channel' => 'background_process',
      'data' => (object) array(
        'action' => $action,
        'background_process' => $object,
        'timestamp' => microtime(TRUE),
      ),
      'callback' => 'nodejsBackgroundProcess',
    );
    drupal_alter('background_process_message', $message);
    nodejs_send_content_channel_message($message);
  }
}