var participants = roomObj.getParticipants();
for (var i = 0; i < participants.length; i++) {
participants.sendMessage('Hello');
}
After that loop stream crashes and had to be restarted.
Please provide a message received handler code. Do you start advert playback on client side when message is received by client?
Also, please check server log files if clients requested VOD from server. If yes, this explains what's happens as we mentioned above.
If no playStream requests, and clients did not received message, this means RoomApi backend application is overloaded by 700 simultaneous requests. In this case we recommend to refactor the workflow by moving it to server side as follows:
1. Publish main stream to the server, for example "paid_stream"
2. Create a mixer and add main stream to it:
Code:
POST /rest-api/mixer/startup HTTP/1.1
{
"uri": "mixer://mixer1",
"localStreamName": "free_stream",
"hasVideo": false
}
POST /rest-api/mixer/add HTTP/1.1
{
"uri": "mixer://mixer1",
"remoteStreamName": "paid_stream"
}
3. Free clients subscribe to free_stream, paid clients sibscribe to paid_stream
4. On "Play advert" click, capture VOD from advert.mp4, add this stream to the mixer and remove main stream from mixer:
Code:
POST /rest-api/vod/startup HTTP/1.1
{
"uri":"vod://advert.mp4"
"localStreamName": "advert_stream"
}
POST /rest-api/mixer/add HTTP/1.1
{
"uri": "mixer://mixer1",
"remoteStreamName": "advert_stream"
}
POST /rest-api/mixer/remove HTTP/1.1
{
"uri": "mixer://mixer1",
"remoteStreamName": "paid_stream"
}
4. Periodically check if VOD stream is playing:
Code:
POST /rest-api/vod/find HTTP/1.1
{
"localStreamName": "advert_stream"
}
This will return 404 when advert stream is finished
5. Add main stream back to the mixer
Code:
POST /rest-api/mixer/add HTTP/1.1
{
"uri": "mixer://mixer1",
"remoteStreamName": "paid_stream"
}
In this case, paid subscribers will hear the main stream, free subscribers will hear advertising over the main stream without any client side action.