WAMP->prefixes[$curie] = $uri; } public function onOpen(Connection $conn) { $conn->WAMP = new \StdClass; $conn->WAMP->prefixes = array(); $conn->WAMP->subscriptions = array(); return $this->_app->onOpen($conn); } /** * @{inherit} * @throws Exception * @throws JSONException */ public function onMessage(Connection $from, $msg) { if (null === ($json = @json_decode($msg, true))) { throw new JSONException; } switch ($json[0]) { case 1: return $this->addPrefix($from, $json[1], $json[2]); break; case 2: array_shift($json); array_unshift($json, $from); return call_user_func_array(array($this->_app, 'onCall'), $json); break; case 5: return $this->_app->onSubscribe($from, $this->getUri($from, $json[1])); break; case 6: return $this->_app->onUnSubscribe($from, $this->getUri($from, $json[1])); break; case 7: return $this->_app->onPublish($from, $this->getUri($from, $json[1]), $json[2]); break; default: throw new Exception('Invalid message type'); } } /** * Get the full request URI from the connection object if a prefix has been established for it * @param Ratchet\Resource\Connection * @param ... * @return string */ protected function getUri(Connection $conn, $uri) { $ret = (isset($conn->WAMP->prefixes[$uri]) ? $conn->WAMP->prefixes[$uri] : $uri); } public function __construct(ServerInterface $app) { $this->_app = $app; } public function onClose(Connection $conn) { return $this->_app->onClose($conn); } public function onError(Connection $conn, \Exception $e) { return $this->_app->onError($conn, $e); } }