class Nodejs in Node.js integration 6
Same name and namespace in other branches
- 7 nodejs.module \Nodejs
Hierarchy
- class \Nodejs
Expanded class hierarchy of Nodejs
1 string reference to 'Nodejs'
- nodejs_menu in ./
nodejs.module - Implements hook_menu().
File
- ./
nodejs.module, line 584
View source
class Nodejs {
public static $messages = array();
public static $config = NULL;
public static $baseUrl = NULL;
public static $headers = NULL;
public static function initConfig() {
if (!isset(self::$config)) {
self::$config = nodejs_get_config();
self::$headers = array(
'NodejsServiceKey' => self::$config['serviceKey'],
);
self::$baseUrl = nodejs_get_url(self::$config);
}
}
public static function getMessages() {
return self::$messages;
}
public static function enqueueMessage(StdClass $message) {
self::$messages[] = $message;
}
public static function sendMessages() {
foreach (self::$messages as $message) {
self::sendMessage($message);
}
}
public static function sendMessage(StdClass $message) {
self::initConfig();
drupal_alter('nodejs_message', $message);
$message->clientSocketId = str_replace("/", "", nodejs_get_client_socket_id());
$request_method = 'POST';
$request_retry = 3;
$data = json_encode($message);
return drupal_http_request(self::$baseUrl . 'nodejs/publish', self::$headers, $request_method, $data, $request_retry);
}
public static function setUserPresenceList($uid, array $uids) {
self::initConfig();
return drupal_http_request(self::$baseUrl . "nodejs/user/presence-list/{$uid}/" . implode(',', $uids), self::$headers);
}
public static function logoutUser($token) {
self::initConfig();
return drupal_http_request(self::$baseUrl . "nodejs/user/logout/{$token}", self::$headers);
}
public static function sendContentTokenMessage($message) {
self::initConfig();
$message->clientSocketId = nodejs_get_client_socket_id();
$request_method = 'POST';
$request_retry = 3;
$data = json_encode($message);
return drupal_http_request(self::$baseUrl . 'nodejs/content/token/message', self::$headers, $request_method, $data, $request_retry);
}
public static function sendContentToken($message) {
self::initConfig();
$request_method = 'POST';
$request_retry = 3;
$data = json_encode($message);
return drupal_http_request(self::$baseUrl . 'nodejs/content/token', self::$headers, $request_method, $data, $request_retry);
}
public static function kickUser($uid) {
self::initConfig();
return drupal_http_request(self::$baseUrl . "nodejs/user/kick/{$uid}", self::$headers);
}
public static function addUserToChannel($uid, $channel) {
self::initConfig();
return drupal_http_request(self::$baseUrl . "nodejs/user/channel/add/{$channel}/{$uid}", self::$headers);
}
public static function removeUserFromChannel($uid, $channel) {
self::initConfig();
return drupal_http_request(self::$baseUrl . "nodejs/user/channel/remove/{$channel}/{$uid}", self::$headers);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
Nodejs:: |
public static | property | ||
Nodejs:: |
public static | property | ||
Nodejs:: |
public static | property | ||
Nodejs:: |
public static | property | ||
Nodejs:: |
public static | function | ||
Nodejs:: |
public static | function | ||
Nodejs:: |
public static | function | ||
Nodejs:: |
public static | function | ||
Nodejs:: |
public static | function | ||
Nodejs:: |
public static | function | ||
Nodejs:: |
public static | function | ||
Nodejs:: |
public static | function | ||
Nodejs:: |
public static | function | ||
Nodejs:: |
public static | function | ||
Nodejs:: |
public static | function | ||
Nodejs:: |
public static | function |