Joining session without publishing

Hello,

I’m looking to have a session where there is only one publisher and all other are only subscribed to the session and can have the video from the only publisher.
I’m working on the openvidu-insecure-angular project. The problem is when I connect to the session by subscribing if I dont init the publisher I dont receive the video from the publisher.
I tried to work with changing the tokens when I’m connecting but seems to don’t work.

In clear at the moment, If I’m connected as “admin”, I’ll publish my stream and can watch my own stream, but if use another name, I want to connect myself to the session by subscribing to it without publishing but I’m not able to see the publisher publishing is video. It looks like I’m connected to the session but I’m not able to see anything from the publisher.

Kinds Regards

Hello, you can take a look to openvidu classroom.

https://docs.openvidu.io/en/2.14.0/demos/openvidu-classroom/

This app is a teacher-student case where many students will subscribe to one publisher (teacher).

I’m using the openvidu-insecure-angular and I don’t use the VideoSessionService package.
In the openvidu-classroom project in the video-session.component.ts, I dont get how the token generated got subscriber or publisher role, It looks exactly the same for both, calling the same function generateToken.
The only things I can see is when the role is teacher we create the session and if the role is student we dont.
As I said I already tried to dont init the publisher and so dont publish it. But It looks like I’m connected but cannot see the stream of the publisher…

You just have to call the right methods depending on what you want a particluar client to do.
First of all, when generating a token you must decide the role you want for each user. PUBLISHERS will be able to publish their camera. SUBSCRIBERS will only be able to receive other user’s cameras.

After you call Session.connect(TOKEN) on the client side, if you are a PUBLISHER and you want to publish, you get a Publisher object and you call Session.publish(Publisher)

If you wan to receive remote streams, you add listener Session.on(‘streamCreated’) and you call Session.subscribe(Stream) with the received Stream in that event.

This is all carefully explained in the Cheatsheet section of the docs:

Publish video: https://docs.openvidu.io/en/2.14.0/cheatsheet/publish-unpublish/
Subscribe video: https://docs.openvidu.io/en/2.14.0/cheatsheet/subscribe-unsubscribe/