Open hartois opened 8 years ago
Hmm
$ari->bridges()->getBridge($bridge->getId())->getChannels();
returning channels list
$bridge is an object containing the state of the bridge before the channels were added. I could modify resources to always call ARI, but I'd be a bit worried about the performance. Could also have a refresh option but that's similar to just querying for a new $bridge. Any ideas?
I suggest add to bridge resource a listener to events ChannelEnteredBridge/ChannelLeft Bridge on AriClient May be as option
Good idea. I'll can find the spots in the code that apply this weekend or you can submit a PR if you have the time.
I think that I can not find the time earlier than a few days( If I have free time - I do PR I think that the opportunity to listen to these events on the bridge will also be very convenient. Such as:
$bridge = $client->bridges()->createBridge(uniqid(),'mixing', $bridgeName);
$bridge->on('ChannelEnteredBridge',function($event){
...
do some
...
});
UPD:
I will clarify.
Now if set listener
$bridge->on('ChannelEnteredBridge',function($event){
event will be fired on ALL bridges, but should only on the bridge an object which has been set listener
UPD2: Now I use some workaround
$bridgeId = $bridge->getId();
$bridge->on('ChannelLeftBridge', function (ChannelLeftBridge $event) use($bridgeId){
if($event->getBridge()->getId() !== $bridgeId)
return;
......
some code
......
});
IdentifiableEventInterface has a single getEventId() which should return the string used in emit(). ChannelLeftBridge class then implements this using:
return "{$this->getType()}_{$this->getChannel()->getId()}";
I'm not sure what the best way is to associate an event with a channel and a bridge but maybe change IdentifiableEventInterface::getEventId() to IdentifiableEventInterface::getEventIds() and implement it like:
return array( "{$this->getType()}_{$this->getChannel()->getId()}", "{$this->getType()}_{$this->getBridge()->getId()}" );
Then we could emit using a foreach which would send this event to both the channel and the bridge where we could have Bridge::on(ce)ChannelLeftBridge(...).
Thoughts?
Ability to set a listener on both the channel and the bridge is logical and expected. More exact: if the event involves some more resources, it should be possible to install a listener on this resource. For me it is difficult to say how best to implement this.
Working on 3.0 now so this will be implemented with breaking changes from 2.X soon.
Any news on this issue?
Sorry for ugly view
Also had this problem. In file Resources/Bridge.php I've found that where class variables declared: ` /* @var array Ids of channels participating in this bridge */ private $channelIds; also where method is declared:
/* @return array Ids of channels participating in this bridge */ public function getChannelIds() { return $this->channelIds; }`
we have $channelIds, but where constructor is placed we have channels attribute:
`public function construct(AriClient $client, $response) { parent::construct($client, $response);
$this->bridgeClass = $this->getResponseValue('bridge_class');
$this->bridgeType = $this->getResponseValue('bridge_type');
$this->**channels** = $this->getResponseValue('channels');
$this->creator = $this->getResponseValue('creator');
$this->id = $this->getResponseValue('id');
$this->name = $this->getResponseValue('name');
$this->technology = $this->getResponseValue('technology');
}`
Maybe that is not good, but when I had corrected channels to channelIds in constructor, $bridgeChannelIds = $this->client->bridges()->getBridge($bridgeId)->getChannelIds()
had began working.
Hello.
Calls successfuly added, bridge working, but getChannels() return empty array. What am I doing wrong?