Remove Topic autoDelete option from WAMP
When a Topic reaches 0 subscribers it will be removed New subscriptions to Topics that had the same name will create new Topics refs #185, #198
This commit is contained in:
parent
fe4a97400d
commit
0f827b13c9
@ -19,6 +19,7 @@ CHANGELOG
|
||||
* BC: The Session component implements HttpServerInterface instead of WsServerInterface
|
||||
* BC: PHP 5.3 no longer supported
|
||||
* BC: Update to newer version of react/socket dependency
|
||||
* BC: WAMP topics reduced to 0 subscriptions are deleted, new subs to same name will result in new Topic instance
|
||||
* Significant performance enhancements
|
||||
|
||||
* 0.3.6 (2017-01-06)
|
||||
|
@ -6,13 +6,6 @@ use Ratchet\ConnectionInterface;
|
||||
* A topic/channel containing connections that have subscribed to it
|
||||
*/
|
||||
class Topic implements \IteratorAggregate, \Countable {
|
||||
/**
|
||||
* If true the TopicManager will destroy this object if it's ever empty of connections
|
||||
* @deprecated in v0.4
|
||||
* @type bool
|
||||
*/
|
||||
public $autoDelete = false;
|
||||
|
||||
private $id;
|
||||
|
||||
private $subscribers;
|
||||
|
@ -118,7 +118,7 @@ class TopicManager implements WsServerInterface, WampServerInterface {
|
||||
|
||||
$this->topicLookup[$topic->getId()]->remove($conn);
|
||||
|
||||
if ($topic->autoDelete && 0 === $topic->count()) {
|
||||
if (0 === $topic->count()) {
|
||||
unset($this->topicLookup[$topic->getId()]);
|
||||
}
|
||||
}
|
||||
|
@ -185,21 +185,18 @@ class TopicManagerTest extends \PHPUnit_Framework_TestCase {
|
||||
}
|
||||
|
||||
public static function topicConnExpectationProvider() {
|
||||
return array(
|
||||
array(true, 'onClose', 0)
|
||||
, array(true, 'onUnsubscribe', 0)
|
||||
, array(false, 'onClose', 1)
|
||||
, array(false, 'onUnsubscribe', 1)
|
||||
);
|
||||
return [
|
||||
[ 'onClose', 0]
|
||||
, ['onUnsubscribe', 0]
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider topicConnExpectationProvider
|
||||
*/
|
||||
public function testTopicRetentionFromLeavingConnections($autoDelete, $methodCall, $expectation) {
|
||||
public function testTopicRetentionFromLeavingConnections($methodCall, $expectation) {
|
||||
$topicName = 'checkTopic';
|
||||
list($topic, $attribute) = $this->topicProvider($topicName);
|
||||
$topic->autoDelete = $autoDelete;
|
||||
|
||||
$this->mngr->onSubscribe($this->conn, $topicName);
|
||||
call_user_func_array(array($this->mngr, $methodCall), array($this->conn, $topicName));
|
||||
|
Loading…
Reference in New Issue
Block a user