Sends disconnect reason when server sends Leave request (#801)
* Sends disconnect reason when server sends Leave request * update go.mod
This commit is contained in:
@@ -689,7 +689,9 @@ func (p *ParticipantImpl) Close(sendLeave bool, reason types.ParticipantCloseRea
|
||||
if sendLeave {
|
||||
_ = p.writeMessage(&livekit.SignalResponse{
|
||||
Message: &livekit.SignalResponse_Leave{
|
||||
Leave: &livekit.LeaveRequest{},
|
||||
Leave: &livekit.LeaveRequest{
|
||||
Reason: reason.ToDisconnectReason(),
|
||||
},
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
@@ -123,6 +123,35 @@ func (p ParticipantCloseReason) String() string {
|
||||
}
|
||||
}
|
||||
|
||||
func (p ParticipantCloseReason) ToDisconnectReason() livekit.DisconnectReason {
|
||||
switch p {
|
||||
case ParticipantCloseReasonClientRequestLeave:
|
||||
return livekit.DisconnectReason_CLIENT_INITIATED
|
||||
case ParticipantCloseReasonRoomManagerStop:
|
||||
return livekit.DisconnectReason_SERVER_SHUTDOWN
|
||||
case ParticipantCloseReasonVerifyFailed, ParticipantCloseReasonJoinFailed, ParticipantCloseReasonJoinTimeout:
|
||||
// expected to be connected but is not
|
||||
return livekit.DisconnectReason_JOIN_FAILURE
|
||||
case ParticipantCloseReasonPeerConnectionDisconnected:
|
||||
return livekit.DisconnectReason_STATE_MISMATCH
|
||||
case ParticipantCloseReasonDuplicateIdentity, ParticipantCloseReasonMigrationComplete, ParticipantCloseReasonStale:
|
||||
return livekit.DisconnectReason_DUPLICATE_IDENTITY
|
||||
case ParticipantCloseReasonServiceRequestRemoveParticipant:
|
||||
return livekit.DisconnectReason_PARTICIPANT_REMOVED
|
||||
case ParticipantCloseReasonServiceRequestDeleteRoom:
|
||||
return livekit.DisconnectReason_ROOM_DELETED
|
||||
case ParticipantCloseReasonSimulateMigration:
|
||||
return livekit.DisconnectReason_DUPLICATE_IDENTITY
|
||||
case ParticipantCloseReasonSimulateNodeFailure:
|
||||
return livekit.DisconnectReason_SERVER_SHUTDOWN
|
||||
case ParticipantCloseReasonSimulateServerLeave:
|
||||
return livekit.DisconnectReason_SERVER_SHUTDOWN
|
||||
default:
|
||||
// the other types will map to unknown reason
|
||||
return livekit.DisconnectReason_UNKNOWN_REASON
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------
|
||||
|
||||
//counterfeiter:generate . Participant
|
||||
|
||||
@@ -218,6 +218,7 @@ func (r *RoomManager) StartSession(
|
||||
Message: &livekit.SignalResponse_Leave{
|
||||
Leave: &livekit.LeaveRequest{
|
||||
CanReconnect: true,
|
||||
Reason: livekit.DisconnectReason_STATE_MISMATCH,
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user