Skip to content

Add SfuErrorCode.liveEnded #951

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

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
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
40 changes: 21 additions & 19 deletions packages/stream_video/lib/src/call/call.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1116,25 +1116,27 @@ class Call {
}
// error event
else if (sfuEvent is SfuErrorEvent) {
switch (sfuEvent.error.reconnectStrategy) {
case SfuReconnectionStrategy.rejoin:
case SfuReconnectionStrategy.fast:
case SfuReconnectionStrategy.migrate:
_logger.w(
() =>
'[onSfuEvent] SFU error: ${sfuEvent.error}, reconnect strategy: ${sfuEvent.error.reconnectStrategy}',
);
await _reconnect(sfuEvent.error.reconnectStrategy);
break;
case SfuReconnectionStrategy.disconnect:
_logger.w(
() => '[onSfuEvent] SFU error: ${sfuEvent.error}, leaving call',
);
await leave();
break;
case SfuReconnectionStrategy.unspecified:
_logger.w(() => '[onSfuEvent] SFU error: ${sfuEvent.error}');
break;
if (sfuEvent.error.code != SfuErrorCode.liveEnded) {
switch (sfuEvent.error.reconnectStrategy) {
case SfuReconnectionStrategy.rejoin:
case SfuReconnectionStrategy.fast:
case SfuReconnectionStrategy.migrate:
_logger.w(
() =>
'[onSfuEvent] SFU error: ${sfuEvent.error}, reconnect strategy: ${sfuEvent.error.reconnectStrategy}',
);
await _reconnect(sfuEvent.error.reconnectStrategy);
break;
case SfuReconnectionStrategy.disconnect:
_logger.w(
() => '[onSfuEvent] SFU error: ${sfuEvent.error}, leaving call',
);
await leave();
break;
case SfuReconnectionStrategy.unspecified:
_logger.w(() => '[onSfuEvent] SFU error: ${sfuEvent.error}');
break;
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,8 @@ extension SfuErrorCodeExtension on sfu_models.ErrorCode {
return SfuErrorCode.tooManyRequests;
case sfu_models.ErrorCode.ERROR_CODE_UNAUTHENTICATED:
return SfuErrorCode.unauthenticated;
case sfu_models.ErrorCode.ERROR_CODE_LIVE_ENDED:
return SfuErrorCode.liveEnded;
default:
throw StateError('unexpected error code: $this');
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ enum SfuErrorCode {
participantNotFound,
participantMediaTransportFailure,
callNotFound,
liveEnded,
requestValidationFailed,
unauthenticated,
permissionDenied,
Expand Down
6 changes: 5 additions & 1 deletion packages/stream_video/lib/src/ws/ws.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ enum StreamWebSocketCloseCode {
// */
goingAway(1001),

policyViolation(1008),

// /**
// * The error code used when the SFU connection is unhealthy.
// * Usually, this means that no message has been received from the SFU for
Expand All @@ -43,7 +45,9 @@ enum StreamWebSocketCloseCode {
final int value;

static bool isIntentionalClosure(int? code) =>
code == normalClosure.value || code == goingAway.value;
code == normalClosure.value ||
code == goingAway.value ||
code == policyViolation.value;
}

/// A simple wrapper around [WebSocketChannel] to make it easier to use.
Expand Down