nodejs_ajax.module in Node.js integration 8
File
nodejs_ajax/nodejs_ajax.module
View source
<?php
function nodejs_ajax_nodejs_handlers_info() {
return [
'nodejs_ajax/nodejs_ajax',
];
}
function nodejs_ajax_nodejs_user_channels($account) {
return [
'nodejs_ajax_broadcast',
];
}
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);
}