Added subscribers filtering in topic broadcasting for taking into account exclude & eligible data
This commit is contained in:
parent
3dc69de9d3
commit
0b5208507f
@ -32,10 +32,21 @@ class Topic implements \IteratorAggregate, \Countable {
|
|||||||
/**
|
/**
|
||||||
* Send a message to all the connections in this topic
|
* Send a message to all the connections in this topic
|
||||||
* @param string $msg
|
* @param string $msg
|
||||||
|
* @param array $exclude
|
||||||
|
* @param array $eligible
|
||||||
* @return Topic
|
* @return Topic
|
||||||
*/
|
*/
|
||||||
public function broadcast($msg) {
|
public function broadcast($msg, array $exclude, array $eligible) {
|
||||||
|
$useEligible = count($eligible);
|
||||||
foreach ($this->subscribers as $client) {
|
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);
|
$client->event($this->id, $msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -99,4 +99,11 @@ class WampConnection extends AbstractConnectionDecorator {
|
|||||||
public function close($opt = null) {
|
public function close($opt = null) {
|
||||||
$this->getConnection()->close($opt);
|
$this->getConnection()->close($opt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get session ID
|
||||||
|
*/
|
||||||
|
public function getSessionId() {
|
||||||
|
return $this->WAMP->sessionId;
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user