Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

integrating an external auth service - peer id/uid #202

Open
Knat-Dev opened this issue May 13, 2021 · 3 comments
Open

integrating an external auth service - peer id/uid #202

Knat-Dev opened this issue May 13, 2021 · 3 comments

Comments

@Knat-Dev
Copy link

Knat-Dev commented May 13, 2021

I'm sorry for not using a template, but it isn't a bug report nor a feature request.

I'm trying to integrate my own auth service (uses nestjs along with typeorm , postgres and jwt) along with the sfu, using ion-sdk-js with react on the frontend.
First of all, I managed to create a working conference (currently audio only for I have no webcam) call easily using ion-sfu's docker image and the frontend library, it was an awesome experience so that's first!
I messed around with the frontend library, I can see a way to send a user id to the sfu and it works great (I can see the peer id being printed in the signaling process logs).
the problem is I don't see how I'm supposed to consume this value (nor do I know whether I should).
I read the FAQ of ion-sfu's git repo and it was mentioned that the apps should use the streamId and map that to a user value of a sort.

the streamId doesn't seem to contain a hint of peer info or uid so I'd appreciate it if anyone could point me to an article about how to do such a mapping
I stil lwonder why do we pass a uid to the Join function if we can't use it along with the incoming tracks or onspeaker, or maybe there's a best practice that I missed?

Thanks in advance

Edit: I can see how I could make use of a data channel to pass user data along, is this the best way though?

@manishiitg
Copy link

Yes, i am also facing the same issue. you will have to use data channels to manage this

@manishiitg
Copy link

@Knat-Dev when u create localStream you can get its "id" using localStream.id

and then u can pass that along the data channel with user id.

this via the data channel you are able to send your user information with stream id

also there is another problem in this,

pion works on the basis of track instead of a stream.

so we have an onTrack function, and this will be called separately for audio/ video track

if you re-negotiate a track again the ontrack function is callsed with the new stream id

@Knat-Dev
Copy link
Author

Knat-Dev commented May 18, 2021

Thanks for the reply, I already managed to work it out using a data channel.

This is what I did for those who come by this issue in the future:

  1. create a new signaling object with IonSFUJSONRPCSignal (url: "ws://localhost:7000/ws" when working locally)
  2. when the signal channel is open, client must join the sfu.
  3. after joining, the client can create streams (LocalStream.getUserMedia / LocalStream.getDisplayMedia) and publish it to the sfu.
  4. after publishing, we create a data channel for sending user data and store a reference to it in a variable (I'll be using useRef for I use react).
  5. when the data channel opens, send a "joined" event to other peers in the channel.
  6. when a "joined" event is received, echo your user info to the peers along with all streamIds.

This is what I implemented to integrate my auth service.
If anyone has a better solution, please share it :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants