Reenable subscribe message with security #6
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Reenable subscribe message that was commented in #2 and add proper JWT check.
This closes mozilla#83 and mozilla#86
This is to support use case like 1-5 publishers and 100 listeners for some sort of webinar, see discussion in mozilla#76
This Subscribe message is currently only useful if:
syncOccupants
api to sync subscriptions to publishers via the newcreateListener
and to not create a publisher connection for you so that all participants don't subscribe automatically to you that make explode the number of connections the server needs to maintain. In the experiment add createListener with the subscribe message naf-janus-adapter#9 I only created thecreateListener
function. Also be aware of Ghost avatar in the room after the user auto reconnect (master branch) naf-janus-adapter#21 that is not fixed yet.Having written the above, rewritten the api documentation, reading again my comments on mozilla#76 and knowing that
Subscribe
message is exactly the same asJoin
with{media: UserId}
except it doesn't has the listener user_id or room_id, and we don't maintain a list of them in the switchboard.It would be more useful if we do the following changes instead:
Subscribe
message code completely{kind: ["publisher"|"listener"|"subscriber"], data: true, notifications: true}
(addJoinKind::Listener
)switchboard.join_listener
)process_join
, if listener, useswitchboard.join_listener
and send to all publishers and listeners{ "event": "join", "kind": "listener", "user_id": user_id, "room_id": room_id }
, if publisher, send with the event with"kind": "publisher"
. In naf janus adapter, you can subscribe to their audio/video if"kind": "publisher"
, otherwise just maintain a list of listeners or counter of listeners in the room.get_all_users
toget_publishers
, add a newget_listeners
users_occupying
similar topublishers_occupying
but return publishers and listenersdata_recipients_for
, useusers_occupying
instead ofpublishers_occupying
process_join
response send the list of publishers in users array as today + listeners array:{"users:": ["publisherId1", "publisherId2"], "listeners": ["listenerId1", "listenerId2"]}
(rename users to publishers if we don't care about backward compatibility, also modify theinitialOccupants
line in the adapter that add those publishers to the available occupants to subscribe)data:true
to detect if the connection is a publisher and look atkind: "publisher"
field (we can fallback to usingdata:true
if kind is not defined if we care about backward compatibility)process_data
anddestroy_session
(leave event),process_join
(join event), instead of usingswitchboard.publishers_occupying
useswitchboard.users_occupying
that returns both publishers and listeners. Indestroy_session
, add thekind: "publisher"|"listener"
field to the leave event. Also probably fix sending the leave event if the main connection is closed and not all connections to fix Ghost avatar in the room after the user auto reconnect (master branch) naf-janus-adapter#21. This way naf adapter can unsubscribe if the participant was publisher, remove the participant for the users list if publisher or listener.{kind: ["publisher"|"listener"]}
to switch the main connection to publisher or back to listener, send aswitch
event to all publishers and listeners so they can subscribe if it became a publisher or unsubscribe if it became a listener. (switchboard.switch_to_publisher
,switchboard.switch_to_listener
)Changes in naf adapter master branch that maintain a separate
availableOccupants
andoccupants
lists andsyncOccupants
api:this.createPublisher()
call) with Join messagekind: "listener"
orkind: "publisher"
createSubscriber
to addkind:subscriber
sendSwitch
with paramkind: "publisher"|"listener"
that send theswitch
event.switch
event, more or less treat it like a leave followed by a joinavailableOccupants
to have the information of publisher or listener or two separate arrays.adapter.requestedOccupants = adapter.availableOccupants;
, useadapter.requestedOccupants = []
and maintain the list of occupants (publishers) you want to subscribe to, for example based on a private audio zone you are in.requestedOccupants
array and callsyncOccupants()
. Note: the callsyncOccupants()
in the join handler in the adapter is not really useful here because we don't use an external users list backend and are not callingsyncOccupants(newOccupants)
when the users list change.This way, you can use the plugin without any additional backend, you can also choose to keep reliableTransport/unreliableTransport to datachannel or websocket, and keep networked updates and chat on it.
Note: the server still maintain a WebRTC connection for the participant, even if the participant don't use datachannel, audio or video. We can probably remove creation of the datachannels if reliableTransport and unreliableTransport are not set to "datachannel" (this is the default, so meaning you set it to "websocket"), but we still keep a main WebRTC connection with an inactive audio track and an inactive video track.