From 9b14684cbe772f17a462aa6f5e228b48a3d9a3d9 Mon Sep 17 00:00:00 2001 From: Chris Boden Date: Mon, 16 Jan 2012 22:54:28 -0500 Subject: [PATCH] WAMP Event Action Added the Event action in WAMP (like SendMessage) Confirmed subscribe, unsubscribe, publish, event working in WAMP --- lib/Ratchet/Application/WAMP/App.php | 14 +++++--------- .../Application/WAMP/Command/Action/Event.php | 17 +++++++++++++++++ 2 files changed, 22 insertions(+), 9 deletions(-) create mode 100644 lib/Ratchet/Application/WAMP/Command/Action/Event.php diff --git a/lib/Ratchet/Application/WAMP/App.php b/lib/Ratchet/Application/WAMP/App.php index f97e17b..e0f79d9 100644 --- a/lib/Ratchet/Application/WAMP/App.php +++ b/lib/Ratchet/Application/WAMP/App.php @@ -6,6 +6,7 @@ use Ratchet\Resource\Connection; /** * WebSocket Application Messaging Protocol + * * +--------------+----+------------------+ * | Message Type | ID | DIRECTION | * |--------------+----+------------------+ @@ -63,29 +64,24 @@ class App implements WebSocketAppInterface { break; case 2: - $ret = $this->_app->onCall($from, $json[1], $json[2]); + return $this->_app->onCall($from, $json[1], $json[2]); break; case 5: - $ret = $this->_app->onSubscribe($from, $json[1]); + return $this->_app->onSubscribe($from, $json[1]); break; case 6: - $ret = $this->_app->onUnSubscribe($from, $json[1]); + return $this->_app->onUnSubscribe($from, $json[1]); break; case 7: - $ret = $this->_app->onPublish($from, $json[1], $json[2]); + return $this->_app->onPublish($from, $json[1], $json[2]); break; default: throw new Exception('Invalid message type'); } - - // create method to loop through $ret - // json_encode messages, return $ret back to WebSocket - - return $ret; } public function __construct(ServerInterface $app) { diff --git a/lib/Ratchet/Application/WAMP/Command/Action/Event.php b/lib/Ratchet/Application/WAMP/Command/Action/Event.php new file mode 100644 index 0000000..2f4a389 --- /dev/null +++ b/lib/Ratchet/Application/WAMP/Command/Action/Event.php @@ -0,0 +1,17 @@ +setMessage(json_encode(array(8, $uri, (string)$msg))); + } +} \ No newline at end of file