send() public method

public send ( $client, $msg )
Example #1
0
 /**
  * Updates the clients presence.
  *
  * @param WebSocket $ws 
  * @param string|null $gamename 
  * @param boolean $idle
  * @return boolean 
  */
 public function updatePresence($ws, $gamename, $idle)
 {
     $idle = $idle == false ? null : true;
     $ws->send(['op' => 3, 'd' => ['game' => !is_null($gamename) ? ['name' => $gamename] : null, 'idle_since' => $idle]]);
     return true;
 }
Example #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');
     }
 }