@@ -490,12 +490,8 @@ public async Task DoJoin(JoinCallData joinCallData, CancellationToken cancellati
490490 $ "{ nameof ( DoJoin ) } - Skipped join call request: callExists: { callCredentialsExists } , isRejoin: { isRejoin } , isMigration: { isMigration } ") ;
491491 }
492492
493- ActiveCall = call ?? throw new NullReferenceException ( nameof ( call ) ) ;
494-
495- if ( ActiveCall . Credentials == null || string . IsNullOrEmpty ( ActiveCall . Credentials . Token ) )
496- {
497- _logs . ErrorIfDebug ( $ "{ nameof ( DoJoin ) } - Missing credentials!") ;
498- }
493+ ActiveCall = call ;
494+ EnsureCallHasJoinCredentials ( ActiveCall ) ;
499495
500496 _httpClient = _httpClientFactory ( ActiveCall ) ;
501497
@@ -745,13 +741,46 @@ private async Task<StreamCall> ExecuteJoinRequest(JoinCallData data, Cancellatio
745741
746742 var joinCallResponse
747743 = await _lowLevelClient . InternalVideoClientApi . JoinCallAsync ( data . Type , data . Id , joinCallRequest ) ;
744+ if ( joinCallResponse == null )
745+ {
746+ throw new InvalidOperationException (
747+ $ "Join call API returned an empty response for `{ data . Type } :{ data . Id } `.") ;
748+ }
749+
748750 var streamCall = _cache . TryCreateOrUpdate ( joinCallResponse ) ;
751+ if ( streamCall == null )
752+ {
753+ throw new InvalidOperationException (
754+ $ "Join call API response could not be applied for `{ data . Type } :{ data . Id } `.") ;
755+ }
749756
750757 //StreamTODO: add ring accept logic. Check JS doJoinRequest
751758
752759 return streamCall ;
753760 }
754761
762+ private static void EnsureCallHasJoinCredentials ( StreamCall call )
763+ {
764+ if ( call == null )
765+ {
766+ throw new InvalidOperationException ( "Join call response did not contain call data." ) ;
767+ }
768+
769+ var credentials = call . Credentials ;
770+ if ( credentials == null || string . IsNullOrEmpty ( credentials . Token ) )
771+ {
772+ throw new InvalidOperationException (
773+ $ "Join call response for `{ call . Cid } ` is missing credentials or token.") ;
774+ }
775+
776+ var server = credentials . Server ;
777+ if ( server == null || string . IsNullOrEmpty ( server . Url ) )
778+ {
779+ throw new InvalidOperationException (
780+ $ "Join call response for `{ call . Cid } ` is missing SFU server URL.") ;
781+ }
782+ }
783+
755784 public Task StopAsync ( string reason = "" )
756785 {
757786 if ( UseNativeAudioBindings )
0 commit comments