WAMP Event Action
Added the Event action in WAMP (like SendMessage) Confirmed subscribe, unsubscribe, publish, event working in WAMP
This commit is contained in:
parent
ad302a00d1
commit
9b14684cbe
@ -6,6 +6,7 @@ use Ratchet\Resource\Connection;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* WebSocket Application Messaging Protocol
|
* WebSocket Application Messaging Protocol
|
||||||
|
*
|
||||||
* +--------------+----+------------------+
|
* +--------------+----+------------------+
|
||||||
* | Message Type | ID | DIRECTION |
|
* | Message Type | ID | DIRECTION |
|
||||||
* |--------------+----+------------------+
|
* |--------------+----+------------------+
|
||||||
@ -63,29 +64,24 @@ class App implements WebSocketAppInterface {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 2:
|
case 2:
|
||||||
$ret = $this->_app->onCall($from, $json[1], $json[2]);
|
return $this->_app->onCall($from, $json[1], $json[2]);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 5:
|
case 5:
|
||||||
$ret = $this->_app->onSubscribe($from, $json[1]);
|
return $this->_app->onSubscribe($from, $json[1]);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 6:
|
case 6:
|
||||||
$ret = $this->_app->onUnSubscribe($from, $json[1]);
|
return $this->_app->onUnSubscribe($from, $json[1]);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 7:
|
case 7:
|
||||||
$ret = $this->_app->onPublish($from, $json[1], $json[2]);
|
return $this->_app->onPublish($from, $json[1], $json[2]);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
throw new Exception('Invalid message type');
|
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) {
|
public function __construct(ServerInterface $app) {
|
||||||
|
17
lib/Ratchet/Application/WAMP/Command/Action/Event.php
Normal file
17
lib/Ratchet/Application/WAMP/Command/Action/Event.php
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
<?php
|
||||||
|
namespace Ratchet\Application\WAMP\Command\Action;
|
||||||
|
use Ratchet\Resource\Command\Action\SendMessage;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is an event in the context of a topicURI
|
||||||
|
* This event (message) is to be sent to all subscribers of $uri
|
||||||
|
*/
|
||||||
|
class Event extends SendMessage {
|
||||||
|
/**
|
||||||
|
* @param ...
|
||||||
|
* @param string
|
||||||
|
*/
|
||||||
|
public function setEvent($uri, $msg) {
|
||||||
|
$this->setMessage(json_encode(array(8, $uri, (string)$msg)));
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user