diff --git a/src/Ratchet/Wamp/Topic.php b/src/Ratchet/Wamp/Topic.php index 688195a..c2f7217 100644 --- a/src/Ratchet/Wamp/Topic.php +++ b/src/Ratchet/Wamp/Topic.php @@ -32,10 +32,21 @@ class Topic implements \IteratorAggregate, \Countable { /** * Send a message to all the connections in this topic * @param string $msg + * @param array $exclude + * @param array $eligible * @return Topic */ - public function broadcast($msg) { + public function broadcast($msg, array $exclude, array $eligible) { + $useEligible = count($eligible); foreach ($this->subscribers as $client) { + if(in_array($client->getSessionId(), $exclude)) { + continue; + } + + if($useEligible && !in_array($client->getSessionId(), $eligible)) { + continue; + } + $client->event($this->id, $msg); } @@ -85,4 +96,4 @@ class Topic implements \IteratorAggregate, \Countable { public function count() { return $this->subscribers->count(); } -} \ No newline at end of file +} diff --git a/src/Ratchet/Wamp/WampConnection.php b/src/Ratchet/Wamp/WampConnection.php index de13844..4004843 100644 --- a/src/Ratchet/Wamp/WampConnection.php +++ b/src/Ratchet/Wamp/WampConnection.php @@ -99,4 +99,11 @@ class WampConnection extends AbstractConnectionDecorator { public function close($opt = null) { $this->getConnection()->close($opt); } -} \ No newline at end of file + + /** + * Get session ID + */ + public function getSessionId() { + return $this->WAMP->sessionId; + } +}