Reputation: 1455
I have an application that has multiple publishers and I want to go from one to the other, subscribe for a few seconds, and move on.
I put a unique id in the Data property when I created the tokens.
How can I select a specific stream from the session object?... or just how to I select the desired stream?
Upvotes: 1
Views: 516
Reputation: 1455
I think I have the answer but I'm not sure it's the best way.
On the publisher streamCreated
event, I capture the event.stream
from the event in a hash table with the key set as the person's id. Then I call the subscribe
method on session object and pass in the stream from the hash table and set the target to that of the publishing person's video.
Seems to work fine but I've done so much guessing, I'm not sure if it's luck or correct!
Upvotes: 1
Reputation: 294
OpenTok QA staff here,
You're right. For every publisher that creates a stream, you will receive a streamCreated event. So, you can store the streamIds, and subscribe to them in a loop, for instance.
Upvotes: 1