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:
@@ -13,7 +13,7 @@ require (
|
|||||||
github.com/google/wire v0.5.0
|
github.com/google/wire v0.5.0
|
||||||
github.com/gorilla/websocket v1.4.2
|
github.com/gorilla/websocket v1.4.2
|
||||||
github.com/hashicorp/golang-lru v0.5.4
|
github.com/hashicorp/golang-lru v0.5.4
|
||||||
github.com/livekit/protocol v0.13.4-0.20220616085727-d1616e3cb8d7
|
github.com/livekit/protocol v0.13.5-0.20220703041358-5f996eb446f3
|
||||||
github.com/livekit/rtcscore-go v0.0.0-20220524203225-dfd1ba40744a
|
github.com/livekit/rtcscore-go v0.0.0-20220524203225-dfd1ba40744a
|
||||||
github.com/mackerelio/go-osstat v0.2.1
|
github.com/mackerelio/go-osstat v0.2.1
|
||||||
github.com/magefile/mage v1.13.0
|
github.com/magefile/mage v1.13.0
|
||||||
|
|||||||
@@ -133,8 +133,8 @@ github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
|
|||||||
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
|
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
|
||||||
github.com/lithammer/shortuuid/v3 v3.0.6 h1:pr15YQyvhiSX/qPxncFtqk+v4xLEpOZObbsY/mKrcvA=
|
github.com/lithammer/shortuuid/v3 v3.0.6 h1:pr15YQyvhiSX/qPxncFtqk+v4xLEpOZObbsY/mKrcvA=
|
||||||
github.com/lithammer/shortuuid/v3 v3.0.6/go.mod h1:vMk8ke37EmiewwolSO1NLW8vP4ZaKlRuDIi8tWWmAts=
|
github.com/lithammer/shortuuid/v3 v3.0.6/go.mod h1:vMk8ke37EmiewwolSO1NLW8vP4ZaKlRuDIi8tWWmAts=
|
||||||
github.com/livekit/protocol v0.13.4-0.20220616085727-d1616e3cb8d7 h1:7EOPqrzXSKLvFTYIEeQaH2kuLswCQ0Q7Hb3wL11RlnE=
|
github.com/livekit/protocol v0.13.5-0.20220703041358-5f996eb446f3 h1:aKvC6QqcR7HO1X0AQhUwLUVojbSd6PLMhjBIWTTg3Gw=
|
||||||
github.com/livekit/protocol v0.13.4-0.20220616085727-d1616e3cb8d7/go.mod h1:BLtSeVmn2rLP37xjzw7gHgaAmkWl3L/L9bPvgSbaOfo=
|
github.com/livekit/protocol v0.13.5-0.20220703041358-5f996eb446f3/go.mod h1:BLtSeVmn2rLP37xjzw7gHgaAmkWl3L/L9bPvgSbaOfo=
|
||||||
github.com/livekit/rtcscore-go v0.0.0-20220524203225-dfd1ba40744a h1:cENjhGfslLSDV07gt8ASy47Wd12Q0kBS7hsdunyQ62I=
|
github.com/livekit/rtcscore-go v0.0.0-20220524203225-dfd1ba40744a h1:cENjhGfslLSDV07gt8ASy47Wd12Q0kBS7hsdunyQ62I=
|
||||||
github.com/livekit/rtcscore-go v0.0.0-20220524203225-dfd1ba40744a/go.mod h1:116ych8UaEs9vfIE8n6iZCZ30iagUFTls0vRmC+Ix5U=
|
github.com/livekit/rtcscore-go v0.0.0-20220524203225-dfd1ba40744a/go.mod h1:116ych8UaEs9vfIE8n6iZCZ30iagUFTls0vRmC+Ix5U=
|
||||||
github.com/mackerelio/go-osstat v0.2.1 h1:5AeAcBEutEErAOlDz6WCkEvm6AKYgHTUQrfwm5RbeQc=
|
github.com/mackerelio/go-osstat v0.2.1 h1:5AeAcBEutEErAOlDz6WCkEvm6AKYgHTUQrfwm5RbeQc=
|
||||||
|
|||||||
@@ -689,7 +689,9 @@ func (p *ParticipantImpl) Close(sendLeave bool, reason types.ParticipantCloseRea
|
|||||||
if sendLeave {
|
if sendLeave {
|
||||||
_ = p.writeMessage(&livekit.SignalResponse{
|
_ = p.writeMessage(&livekit.SignalResponse{
|
||||||
Message: &livekit.SignalResponse_Leave{
|
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
|
//counterfeiter:generate . Participant
|
||||||
|
|||||||
@@ -218,6 +218,7 @@ func (r *RoomManager) StartSession(
|
|||||||
Message: &livekit.SignalResponse_Leave{
|
Message: &livekit.SignalResponse_Leave{
|
||||||
Leave: &livekit.LeaveRequest{
|
Leave: &livekit.LeaveRequest{
|
||||||
CanReconnect: true,
|
CanReconnect: true,
|
||||||
|
Reason: livekit.DisconnectReason_STATE_MISMATCH,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user