function hook_nodejs_user_channels in Node.js integration 7
Same name and namespace in other branches
- 8 nodejs.api.php \hook_nodejs_user_channels()
Define a list of socket.io channels the user will be automatically added to, upon being registered / authenticated in the Node JS server.
When a user is added to a channel through this function, he will receive then all messages sent to these channels, without having to call manually the nodejs_add_user_to_channel() function to get the user added to the channel.
Note that this hook doesn't provide any kind of wildcard capability, so it's not suitable for all scenarios (e.g: when dealing with channels generated dynamically, for example based on the url the user is visiting). In those cases, the user will have to be added through nodejs_add_user_to_channel().
Parameters
stdClass $account: The Drupal account of the user for which the allowed channels are being checked. This may be an anonymous user.
Return value
array An array of socket.io channels to which the user will be granted access.
4 functions implement hook_nodejs_user_channels()
Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.
- nodejs_ajax_nodejs_user_channels in nodejs_ajax/
nodejs_ajax.module - Implements hook_nodejs_user_channels().
- nodejs_nodejs_user_channels in ./
nodejs.module - Implements hook_nodejs_user_channels().
- nodejs_subscribe_nodejs_user_channels in nodejs_subscribe/
nodejs_subscribe.module - Implements hook_nodejs_user_channels().
- nodejs_watchdog_nodejs_user_channels in nodejs_watchdog/
nodejs_watchdog.module - Implements hook_nodejs_user_channels().
1 invocation of hook_nodejs_user_channels()
- nodejs_auth_check in ./
nodejs.module - Checks the given key to see if it matches a valid session.
File
- ./
nodejs.api.php, line 66 - API documentation for the Nodejs integration module.
Code
function hook_nodejs_user_channels($account) {
// Create a channel for each authenticated user.
if ($account->uid > 0) {
return array(
'nodejs_user_' . $account->uid,
);
}
}