You are here

nodejs_ajax.module in Node.js integration 8

Same filename and directory in other branches
  1. 7 nodejs_ajax/nodejs_ajax.module

File

nodejs_ajax/nodejs_ajax.module
View source
<?php

/**
 * Implements hook_nodejs_handlers_info().
 */
function nodejs_ajax_nodejs_handlers_info() {
  return [
    'nodejs_ajax/nodejs_ajax',
  ];
}

/**
 * Implements hook_nodejs_user_channels().
 */
function nodejs_ajax_nodejs_user_channels($account) {
  return [
    'nodejs_ajax_broadcast',
  ];
}

/**
 * Send some commands to the user asynchronously.
 *
 * @param array $commands 
 * @param array $options 
 */
function nodejs_ajax_render($commands = array(), $options = array()) {
  $options += array(
    'channel' => 'nodejs_user_',
    'uid' => NULL,
  );
  if (!is_null($options['uid'])) {
    $channel = $options['channel'] . $options['uid'];
  }
  $message = (object) array(
    'channel' => $channel,
    'commands' => $commands,
  );
  if (isset($options['callback'])) {
    $message->callback = $options['callback'];
  }
  return nodejs_send_message($message);
}

Functions

Namesort descending Description
nodejs_ajax_nodejs_handlers_info Implements hook_nodejs_handlers_info().
nodejs_ajax_nodejs_user_channels Implements hook_nodejs_user_channels().
nodejs_ajax_render Send some commands to the user asynchronously.