Reputation: 100
There is a public room initially and the users subscribes or join the public room and then each subscriber have the option to "make it private" .
once the any of the subscriber click on "make it private" option , then the rest of all subscriber will get dis-connected from there browser but connected with the room creator or publisher .
But on other subscriber they will not able to show the person who click on make it private options. Because the person get dis-connected from other subscriber screen and only shown on the publisher screen .
So the person who click on "make it private" can have 1-1 chat . I mean the person who click "make it private" option and publisher .
But on Publisher screen all users screen should be shown .
function makeItPrivate() {
for (var i = 0 ; i < subscriberEvent.length; i++) {
if (session.connection.id != subscriberEvent[i].connection.connectionId) {
if (subscriberEvent[0].connection.connectionId != subscriberEvent[i].connection.connectionId) {
session.forceUnpublish(stream);
}
}
}
}
Upvotes: 0
Views: 72
Reputation: 61
You can either disconnect other users from the session or make them unpublish the stream, but you can't make them unsubscribe to the published streams. The only way to do is, if one of the subscribers wants to chat privately with the creator, he should dispatch the signal to all the clients, on receiving the signal, they should stop subscribing as well as publishing to the session while they are still connected.
If lets say there are 3 users, User1 is the creator, User2 and User3 are the subscribers. If User2 wants private chat, then he should sendSignal to all the clients. You can see how signals are sent from here. Then on receiving the signal, User3 will unsubscribe and unpublish from the session.
Upvotes: 1