function nodejs_send_content_channel_token in Node.js integration 8
Same name and namespace in other branches
- 6 nodejs.module \nodejs_send_content_channel_token()
- 7 nodejs.module \nodejs_send_content_channel_token()
Send a content channel token to Node.js.
Parameters
$channel: The channel to generate the token for.
$notify_on_disconnect: If TRUE, other clients will be notified when this client disconnects.
$user_data: Arbitrary custom data that can be stored with the token. This will be broadcast to other clients when the user connects.
1 call to nodejs_send_content_channel_token()
- nodejs_watchdog_page_attachments_alter in nodejs_watchdog/
nodejs_watchdog.module - Implements hook_page_attachments_alter().
File
- ./
nodejs.module, line 44
Code
function nodejs_send_content_channel_token($channel, $notify_on_disconnect = FALSE, $user_data = FALSE) {
$message = (object) array(
'token' => nodejs_generate_content_token(),
'channel' => $channel,
'notifyOnDisconnect' => $notify_on_disconnect,
'userData' => $user_data,
);
// Http request went ok, process Node.js server response.
if ($node_response = nodejs_get_nodejs()
->sendContentToken($message)) {
if ($node_response->status == 'success') {
nodejs_get_nodejs()
->enqueueContentToken($channel, $message->token);
$node_response->token = $message->token;
return $node_response;
}
else {
\Drupal::logger('nodejs')
->error(t('Error sending content channel token for channel "%channel". Node.js server response: %error', array(
'%channel' => $channel,
'%error' => $node_response->error,
)));
return FALSE;
}
}
else {
return FALSE;
}
}