Skip to content

Commit 0f5b92f

Browse files
committed
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. i.e.: ROOM_DELETED, MIGRATION, SERVER_SHUTDOWN, CONNECTION_TIMEOUT mean different things and can 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 UKNOWN_REASON, which is makes sense as OtherReason.
1 parent 29efed7 commit 0f5b92f

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

callback.go

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,11 @@ const (
130130
RejectedByUser DisconnectionReason = "rejected by remote user"
131131
Failed DisconnectionReason = "connection to room failed"
132132
RoomClosed DisconnectionReason = "room closed"
133+
RoomDeleted DisconnectionReason = "room deleted"
133134
ParticipantRemoved DisconnectionReason = "removed by server"
134135
DuplicateIdentity DisconnectionReason = "duplicate identity"
136+
Migration DisconnectionReason = "migration"
137+
ServerShutdown DisconnectionReason = "server shutdown"
135138
OtherReason DisconnectionReason = "other reasons"
136139
)
137140

@@ -147,11 +150,21 @@ func GetDisconnectionReason(reason livekit.DisconnectReason) DisconnectionReason
147150
r = RejectedByUser
148151
case livekit.DisconnectReason_ROOM_CLOSED:
149152
r = RoomClosed
153+
case livekit.DisconnectReason_ROOM_DELETED:
154+
r = RoomDeleted
150155
case livekit.DisconnectReason_PARTICIPANT_REMOVED:
151156
r = ParticipantRemoved
152157
case livekit.DisconnectReason_DUPLICATE_IDENTITY:
153158
r = DuplicateIdentity
154-
case livekit.DisconnectReason_JOIN_FAILURE, livekit.DisconnectReason_SIGNAL_CLOSE, livekit.DisconnectReason_STATE_MISMATCH:
159+
case livekit.DisconnectReason_MIGRATION:
160+
r = Migration
161+
case livekit.DisconnectReason_SERVER_SHUTDOWN:
162+
r = ServerShutdown
163+
case livekit.DisconnectReason_JOIN_FAILURE,
164+
livekit.DisconnectReason_SIGNAL_CLOSE,
165+
livekit.DisconnectReason_STATE_MISMATCH,
166+
livekit.DisconnectReason_CONNECTION_TIMEOUT,
167+
livekit.DisconnectReason_SIP_TRUNK_FAILURE:
155168
r = Failed
156169
}
157170
return r

0 commit comments

Comments
 (0)