diff --git a/lib/Ratchet/Application/WAMP/App.php b/lib/Ratchet/Application/WAMP/App.php index a1c6f32..5d4e67d 100644 --- a/lib/Ratchet/Application/WAMP/App.php +++ b/lib/Ratchet/Application/WAMP/App.php @@ -31,13 +31,13 @@ class App implements WebSocketAppInterface { /** * @todo WAMP spec does not say what to do when there is an error with PREFIX... */ - public function addPrefix(Connection $conn, $uri, $curie) { + public function addPrefix(Connection $conn, $curie, $uri) { // validate uri // validate curie // make sure the curie is shorter than the uri - $conn->prefixes[$uri] = $curie; + $conn->WAMP->prefixes[$curie] = $uri; } public function onOpen(Connection $conn) { @@ -60,7 +60,7 @@ class App implements WebSocketAppInterface { switch ($json[0]) { case 1: - return $this->addPrefix($conn, $json[2], $json[1]); + return $this->addPrefix($from, $json[1], $json[2]); break; case 2: @@ -70,15 +70,15 @@ class App implements WebSocketAppInterface { break; case 5: - return $this->_app->onSubscribe($from, $json[1]); + return $this->_app->onSubscribe($from, $this->getUri($from, $json[1])); break; case 6: - return $this->_app->onUnSubscribe($from, $json[1]); + return $this->_app->onUnSubscribe($from, $this->getUri($from, $json[1])); break; case 7: - return $this->_app->onPublish($from, $json[1], $json[2]); + return $this->_app->onPublish($from, $this->getUri($from, $json[1]), $json[2]); break; default: @@ -86,6 +86,16 @@ class App implements WebSocketAppInterface { } } + /** + * 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; }