Understanding auto-generation of room id.

I was exploring mediasoup-demo but I am having difficulties on understanding how server/client auto generate room id and redirect url with parameter room id.

Also can i use server and client separately. I don’t want to serve html file from server or any server side redirects . I want to have complete REST architecture.

Hi Manish,

you are completely free to define the room access in any way you want. In the case of the demo (note that this is just an example to serve as a basis to start out and/or give you ideas how to implement it) the index.jsx creates a random string, if not provided in the GET as roomId, and uses that as a GET parameter within the WebSocket url that is automatically created (see lib/urlFactory.js). This websocket url is then used for a dedicated protoo handler that holds all participants who registered with this roomId. In the mediasoup sphere, “rooms” are called “router”. You are free to define rooms that are made of multiple routers for horizontal scaling etc., but that is probably getting ahead a bit too much.

In general, the demo server parses the information when the websocket connection is established and creates the corresponding room (see server.js).

Also can i use server and client separately

Absolutely, I’m personally using a modified version of the demo server and can connect to it through Android or any other means. Never had any issues.

I want to have complete REST architecture.

WebRTC requires intensive back-and-forth communication, so you’d have a miserable time implementing something with pure REST. The client would essentially need to poll for new information all the time, which would be a nightmare to implement.

1 Like

Thanks @ceggert87 . You explained well. May I see your modified demo if it is opensource. Maybe exploring more demo can clear the working and use of methods more.

Not open source unfortunately - in the case of the modified demo server the changes are very limited though. It’s extremely stable and I didn’t see much necessity to do much about its general functionality. Just added some customization features. The client-side is essentially using the official WebRTC libraries, connects to the demo server via websockets and sends the appropriate messages to be compatible. All working extremely well and if I do any mistakes (i.e. in creating the SDP out of the messages) the debugging of Mediasoup is extremely helpful to localize the issue.


Do you use flutter?

No, plain old Java. I’d suggest going with the official c++ library for Android now anyway - I built the client during the v2 times where no c++ library was available and was too stubborn to start anew, so I migrated instead :D.

1 Like