ionorg / ion-sdk-js

ion javascript sdk
MIT License
102 stars 70 forks source link

await join() issue #203

Closed manishiitg closed 3 years ago

manishiitg commented 3 years ago

Your environment.

What did you do?

This is how my code looks like the outline at least P.S using react

signalRef.current = new IonSFUJSONRPCSignal(host);
clientRef.current = new Client(signalRef.current, webrtcConfig);

await clientRef.current.join(meshidRef.current);

signalRef.current.onopen = async () => {
    ....
})

clientRef.current.ontrack = async (track, stream) => {
   ....
})

await publishStream()

Now the main bug comes here

await clientRef.current.join(meshidRef.current);

if i add an await here then if there is another peer on the call, i don't recieve his onTrack event. only if new peers join i recieve the onTrack not for people already on the call.

What did you expect?

i expect await should only wait for me to join on the call. if i use await it should mean i won't get ontrack of users already on the call

What happened?

billylindeman commented 3 years ago

await clientRef.current.join(meshidRef.current);

this should happen inside your signal.onopen callback

manishiitg commented 3 years ago

yes. i am already doing it inside the onopen callback. i wrote it outside by mistake

signalRef.current = new IonSFUJSONRPCSignal(host);
            clientRef.current = new Client(signalRef.current, webrtcConfig);

            signalRef.current.onopen = async () => {
                setNotification("signal opened...")
                clientRef.current.join(meshidRef.current);
                clearTimeout(joinTimeout.current)

this is the actual code as of now i have removed await from my code

billylindeman commented 3 years ago

Do you set the client.ontrack callback ahead of time? The behavior of await client.join did change recently (it now awaits for the api datachannel to arrive).

manishiitg commented 3 years ago

no my ontrack is after await join not before. i will check by putting it before it and see

billylindeman commented 3 years ago

@manishiitg did this solve your issue?

manishiitg commented 3 years ago

@billylindeman didn't check it yet. will do soon

manishiitg commented 3 years ago

for now just not using await.