From 3a4bdc918c9f27f4860371204f1d034d26922650 Mon Sep 17 00:00:00 2001 From: Chris Boden Date: Sun, 8 Jan 2012 22:15:31 -0500 Subject: [PATCH] WAMP Interface Updated interfaces from app refactor to branch out WAMP on top of WebSocket app --- lib/Ratchet/Application/Server/App.php | 3 ++- lib/Ratchet/Application/WAMP/App.php | 15 +++++++-------- lib/Ratchet/Application/WAMP/JSONException.php | 2 +- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/lib/Ratchet/Application/Server/App.php b/lib/Ratchet/Application/Server/App.php index 8eb8fb0..39e144e 100644 --- a/lib/Ratchet/Application/Server/App.php +++ b/lib/Ratchet/Application/Server/App.php @@ -80,6 +80,7 @@ class App implements ApplicationInterface { declare(ticks = 1); + $host->set_option(SOL_SOCKET, SO_SNDBUF, $this->_buffer_size); $host->set_nonblock()->bind($address, (int)$port)->listen(); do { @@ -105,7 +106,7 @@ class App implements ApplicationInterface { $res = $this->onOpen($conn); } else { $data = $buf = ''; - $bytes = $conn->getSocket()->recv($buf, $this->_buffer_size, 0); + $bytes = $conn->getSocket()->recv($buf, $this->_buffer_size, MSG_DONTWAIT); if ($bytes > 0) { $data = $buf; diff --git a/lib/Ratchet/Application/WAMP/App.php b/lib/Ratchet/Application/WAMP/App.php index cfd320c..2829b47 100644 --- a/lib/Ratchet/Application/WAMP/App.php +++ b/lib/Ratchet/Application/WAMP/App.php @@ -21,16 +21,15 @@ use Ratchet\Resource\Connection; * @link http://www.tavendo.de/autobahn/protocol.html * @todo I can't make up my mind what interface to present to the server application */ -class App implements ApplicationInterface, WebSocketAppInterface { +class App implements WebSocketAppInterface { + protected $_app; + protected static $_incoming = array(1, 2, 5, 6, 7); public function getSubProtocol() { return 'wamp'; } - public function attachHandler(ServerInterface $app) { - } - /** * @todo WAMP spec does not say what to do when there is an error with PREFIX... */ @@ -72,12 +71,12 @@ class App implements ApplicationInterface, WebSocketAppInterface { if ($json[0] == 1) { $this->addPrefix($conn, $json[2], $json[1]); } + + // Determine WAMP message type, call $_this->_app->on(); } - public function __construct(ApplicationInterface $app = null) { - if (null !== $app) { - throw new \InvalidArgumentException('WAMP is the end of the Socket stack, apps build on this must conform to the WAMP protocol'); - } + public function __construct(ServerInterface $app) { + $this->_app = $app; } public function onClose(Connection $conn) { diff --git a/lib/Ratchet/Application/WAMP/JSONException.php b/lib/Ratchet/Application/WAMP/JSONException.php index 8e238c0..c8cb7c1 100644 --- a/lib/Ratchet/Application/WAMP/JSONException.php +++ b/lib/Ratchet/Application/WAMP/JSONException.php @@ -1,7 +1,7 @@