public function testRemoveChannel() { $chn = new Channel('my-channel'); $this->channels->add($chn); $this->assertTrue($this->channels->exists('my-channel')); $this->channels->remove('my-channel'); $this->assertFalse($this->channels->exists('my-channel')); }
/** * @inheritdoc */ public function run(ConnectionInterface $from, \stdClass $package) { $channelName = $package->channel; $chn = $this->channels->get($channelName); if (!$chn) { return; } $chn->removeConnection($from); // remove the channel if it is empty. if (count($chn->getConnections()) === 0) { $this->channels->remove($channelName); } }