コード例 #1
0
 /**
  * {@inheritdoc}
  *
  * @throws \Ratchet\Wamp\Exception
  * @throws \Ratchet\Wamp\JsonException
  */
 public function onMessage(ConnectionInterface $from, $msg)
 {
     $from = $this->connections[$from];
     if (null === ($json = @json_decode($msg, true))) {
         throw new JsonException();
     }
     if (!is_array($json) || $json !== array_values($json)) {
         throw new Exception('Invalid WAMP message format');
     }
     switch ($json[0]) {
         case static::MSG_PREFIX:
             $from->WAMP->prefixes[$json[1]] = $json[2];
             break;
         case static::MSG_CALL:
             array_shift($json);
             $callID = array_shift($json);
             $procURI = array_shift($json);
             if (count($json) == 1 && is_array($json[0])) {
                 $json = $json[0];
             }
             $this->_decorating->onCall($from, $callID, $from->getUri($procURI), $json);
             break;
         case static::MSG_SUBSCRIBE:
             $this->_decorating->onSubscribe($from, $from->getUri($json[1]));
             break;
         case static::MSG_UNSUBSCRIBE:
             $this->_decorating->onUnSubscribe($from, $from->getUri($json[1]));
             break;
         case static::MSG_PUBLISH:
             $exclude = array_key_exists(3, $json) ? $json[3] : null;
             if (!is_array($exclude)) {
                 if (true === (bool) $exclude) {
                     $exclude = array($from->WAMP->sessionId);
                 } else {
                     $exclude = array();
                 }
             }
             $eligible = array_key_exists(4, $json) ? $json[4] : array();
             $this->_decorating->onPublish($from, $from->getUri($json[1]), $json[2], $exclude, $eligible);
             break;
         default:
             throw new Exception('Invalid WAMP message type');
     }
 }
コード例 #2
0
ファイル: TopicManager.php プロジェクト: unkerror/Budabot
 /**
  * {@inheritdoc}
  */
 public function onPublish(ConnectionInterface $conn, $topic, $event, array $exclude, array $eligible)
 {
     $this->app->onPublish($conn, $this->getTopic($topic), $event, $exclude, $eligible);
 }