You are here

function drupalchat_nodejs_drupalchat_send in DrupalChat 7

Same name and namespace in other branches
  1. 7.2 drupalchat_nodejs/drupalchat_nodejs.module \drupalchat_nodejs_drupalchat_send()

Implements hook_drupalchat_send().

File

drupalchat_nodejs/drupalchat_nodejs.module, line 27

Code

function drupalchat_nodejs_drupalchat_send($message) {
  global $user;
  $message->timestamp = date("H:i", $message->timestamp);
  $message->name = $user->name;
  $drupalchat_nodejs_message = (object) array(
    'channel' => 'drupalchat_' . $message->uid2,
    'broadcast' => FALSE,
    'type' => 'newMessage',
    'callback' => 'drupalchatNodejsMessageHandler',
    'data' => drupal_json_encode($message),
  );
  nodejs_enqueue_message($drupalchat_nodejs_message);
  nodejs_add_user_to_channel($user->uid, 'drupalchat_' . $user->uid);
}