コード例 #1
0
 /**
  * Sends a message through the channel
  *
  * @param string $message
  * @return array
  */
 public function send($message, $type = WrenchProtocol::TYPE_TEXT, $masked = true, array $options = array())
 {
     $except = isset($options['except']) ? $options['except'] : false;
     $clients = $this->clients;
     if ($except instanceof Connection) {
         $except = array($except);
     }
     if (is_array($except)) {
         foreach ($except as $connection) {
             if ($connection instanceof Connection) {
                 unset($clients[$connection->getId()]);
             }
         }
     }
     $collected = array();
     foreach ($clients as $client) {
         $collected[] = $client->send(Protocol::toString(Protocol::TYPE_MESSAGE, $this->topic, $message), $type, $masked);
     }
     return $collected;
 }
コード例 #2
0
 /**
  * Logs an application error
  *
  * @see Varspool\WebsocketBundle\Application.Application::log()
  */
 public function log($message, $level = 'info', Connection $client = null)
 {
     if ($this->debug) {
         parent::log($message, $level);
         if ($this->remoteLogging) {
             $log = new stdClass();
             $log->type = 'log';
             $log->level = $level;
             $log->message = $message;
             $log = $this->getJsonPayload($log);
             if ($client) {
                 $client->send(Protocol::toString(Protocol::TYPE_MESSAGE, self::TOPIC_LOG_SERVER, $log));
             } else {
                 $this->getChannel(self::TOPIC_LOG_SERVER)->send($log);
             }
         }
     }
 }