Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

39 changes: 35 additions & 4 deletions Packages/StreamVideo/Runtime/Core/LowLevelClient/RtcSession.cs
Original file line number Diff line number Diff line change
Expand Up @@ -552,6 +552,7 @@ private void ClearSession()

ActiveCall = null;
CallState = CallingState.Unknown;
_httpClient = null;

_trackSubscriptionRequested = false;
_trackSubscriptionRequestInProgress = false;
Expand Down Expand Up @@ -601,10 +602,11 @@ private void TryExecuteSubscribeToTracks()
/// </summary>
private async Task SubscribeToTracksAsync()
{
if (ActiveCall.Participants == null || !ActiveCall.Participants.Any())
if (ActiveCall?.Participants == null || !ActiveCall.Participants.Any())
{
#if STREAM_DEBUG_ENABLED
_logs.Error($"{nameof(SubscribeToTracksAsync)} Ignored - No participants in the call to subscribe tracks for");
_logs.Error(
$"{nameof(SubscribeToTracksAsync)} Ignored - No participants in the call to subscribe tracks for");
#endif

return;
Expand Down Expand Up @@ -640,7 +642,7 @@ private async Task SubscribeToTracksAsync()
return;
}

if (response.Error != null)
if (response?.Error != null)
{
_logs.Error(response.Error.Message);
}
Expand All @@ -655,6 +657,12 @@ private IEnumerable<TrackSubscriptionDetails> GetDesiredTracksDetails()

foreach (var participant in ActiveCall.Participants)
{
if (participant == null)
{
_logs.Error("Cannot subscribe to tracks - participant is null");
continue;
}

if (participant.IsLocalParticipant)
{
continue;
Expand All @@ -668,9 +676,16 @@ private IEnumerable<TrackSubscriptionDetails> GetDesiredTracksDetails()
//This was before changing the IUpdateableFrom<CallParticipantResponseInternalDTO, StreamVideoCallParticipant>.UpdateFromDto
//to extract UserId from User obj

var userId = GetUserId(participant);
if (string.IsNullOrEmpty(userId))
{
_logs.Error($"Cannot subscribe to {trackType} - participant UserId is null or empty. SessionID: {participant.SessionId}");
continue;
}

yield return new TrackSubscriptionDetails
{
UserId = GetUserId(participant),
UserId = userId,
SessionId = participant.SessionId,
TrackType = trackType,
Dimension = requestedVideoResolution.ToVideoDimension()
Expand Down Expand Up @@ -1067,8 +1082,15 @@ private void OnSfuDominantSpeakerChanged(DominantSpeakerChanged dominantSpeakerC
private void OnSfuWebSocketOnError(SfuError obj)
{
_sfuTracer?.Trace(PeerConnectionTraceKey.SfuError, obj);
if (CallState == CallingState.Offline)
{
return;
}

_logs.Error(
$"Sfu Error - Code: {obj.Error_.Code}, Message: {obj.Error_.Message}, ShouldRetry: {obj.Error_.ShouldRetry}");

//StreamTODO: add event here
}

private void OnSfuPinsUpdated(PinsChanged pinsChanged)
Expand Down Expand Up @@ -1164,6 +1186,15 @@ private async Task<TResponse> RpcCallAsync<TRequest, TResponse>(TRequest request
{
//StreamTodo: use rpcCallAsync.GetMethodInfo().Name; instead debugRequestName

if (_httpClient == null)
{
var errorMsg
= $"[RPC Call: {debugRequestName}] Failed - Attempted to execute RPC call but HttpClient is not yet initialized. " +
$"CallState: {CallState}, ActiveCall: {ActiveCall != null}, SessionId: {SessionId ?? "null"}";
_logs.Error(errorMsg);
throw new InvalidOperationException(errorMsg);
}

var skipTracing = debugRequestName == nameof(GeneratedAPI.SendStats);

// Trace the RPC request (except SendStats to avoid noise)
Expand Down
Loading