From 3b14460b872e27d12420829d038c89f513398892 Mon Sep 17 00:00:00 2001 From: prlanzarin <4529051+prlanzarin@users.noreply.github.com> Date: Wed, 30 Apr 2025 13:31:17 +0000 Subject: [PATCH] fix: map remaining livekit.DisconnectReason to SDK's DisconnectReason A few entries in livekit.DisconnectReason are not explicitly mapped to the SDK's DisconnectReason. This causes them to be flagged as "OtherReason", even though some of them could be useful if explicitly mapped. e.g.: ROOM_DELETED, MIGRATION, SERVER_SHUTDOWN, CONNECTION_TIMEOUT mean different things and may be treated differently. Map ROOM_DELETED, MIGRATION and SERVER_SHUTDOWN to unique reasons. Map CONNECTION_TIMEOUT and SIP_TRUNK_FAILURE to `Failed`. The only remaining livekit.DisconnectReason is UNKNOWN_REASON, which makes sense as `OtherReason`. --- callback.go | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/callback.go b/callback.go index cad04ff9..bd59a595 100644 --- a/callback.go +++ b/callback.go @@ -130,8 +130,11 @@ const ( RejectedByUser DisconnectionReason = "rejected by remote user" Failed DisconnectionReason = "connection to room failed" RoomClosed DisconnectionReason = "room closed" + RoomDeleted DisconnectionReason = "room deleted" ParticipantRemoved DisconnectionReason = "removed by server" DuplicateIdentity DisconnectionReason = "duplicate identity" + Migration DisconnectionReason = "migration" + ServerShutdown DisconnectionReason = "server shutdown" OtherReason DisconnectionReason = "other reasons" ) @@ -147,11 +150,21 @@ func GetDisconnectionReason(reason livekit.DisconnectReason) DisconnectionReason r = RejectedByUser case livekit.DisconnectReason_ROOM_CLOSED: r = RoomClosed + case livekit.DisconnectReason_ROOM_DELETED: + r = RoomDeleted case livekit.DisconnectReason_PARTICIPANT_REMOVED: r = ParticipantRemoved case livekit.DisconnectReason_DUPLICATE_IDENTITY: r = DuplicateIdentity - case livekit.DisconnectReason_JOIN_FAILURE, livekit.DisconnectReason_SIGNAL_CLOSE, livekit.DisconnectReason_STATE_MISMATCH: + case livekit.DisconnectReason_MIGRATION: + r = Migration + case livekit.DisconnectReason_SERVER_SHUTDOWN: + r = ServerShutdown + case livekit.DisconnectReason_JOIN_FAILURE, + livekit.DisconnectReason_SIGNAL_CLOSE, + livekit.DisconnectReason_STATE_MISMATCH, + livekit.DisconnectReason_CONNECTION_TIMEOUT, + livekit.DisconnectReason_SIP_TRUNK_FAILURE: r = Failed } return r