You are here

function drupalchat_channel_add in DrupalChat 7.2

Same name and namespace in other branches
  1. 7 drupalchat.module \drupalchat_channel_add()
1 string reference to 'drupalchat_channel_add'
drupalchat_menu in ./drupalchat.module
Implements hook_menu().

File

./drupalchat.module, line 652
Module code for DrupalChat.

Code

function drupalchat_channel_add() {
  global $user;
  if (check_plain(variable_get('drupalchat_polling_method', DRUPALCHAT_AJAX)) == DRUPALCHAT_NODEJS && $user->uid != 0) {
    echo nodejs_add_user_to_channel($user->uid, 'drupalchat_' . $user->uid);
    $message['uid'] = $user->uid;
    $message['name'] = $user->name;
    $drupalchat_nodejs_message = (object) array(
      'channel' => 'drupalchat_' . $user->uid,
      'broadcast' => FALSE,
      'type' => 'sendName',
      'callback' => 'drupalchatNodejsMessageHandler',
      'data' => drupal_json_encode($message),
    );
    echo $user->name;
    nodejs_enqueue_message($drupalchat_nodejs_message);
  }
}