Exemplo n.º 1
0
 function __construct()
 {
     global $wgExtensionFunctions;
     // Extension setup hook
     $wgExtensionFunctions[] = 'WebSocket::setup';
     // Give this client an ID or use that supplied in request
     self::$clientID = array_key_exists('clientID', $_REQUEST) ? $_REQUEST['clientID'] : uniqid('WS');
     // Is this an SSL connection?
     self::$ssl = array_key_exists('HTTPS', $_SERVER) && $_SERVER['HTTPS'];
 }
Exemplo n.º 2
0
 /**
  * Send data to the local WebSocket daemon if active
  */
 private static function sendToWebSocket($queue, $session)
 {
     // Lazy-load the Fake MediaWiki environment and the OD Websocket class from the MediaWiki extension
     if (!defined('WEBSOCKET_VERSION')) {
         require_once __DIR__ . '/WebSocket/WebSocket.php';
         WebSocket::$log = '/var/www/extensions/MediaWiki/WebSocket/ws.log';
         // tmp to match my current daemon
         WebSocket::$rewrite = true;
         WebSocket::setup();
     }
     if (WebSocket::isActive()) {
         // Set the ID of this WebSocket message to the session ID of the sender so the WS server doesn't bounce it back to them
         WebSocket::$clientID = $session;
         // Send queue to all clients
         lgDebug('Sending to WebSocket');
         WebSocket::send('LigminchaGlobal', $queue);
         lgDebug('Sent to WebSocket');
     } else {
         lgDebug('Not sending to WebSocket: not active');
     }
 }