fix kicked message for legacy implementation.

This commit is contained in:
Miroslav Šedivý 2024-09-07 20:10:43 +02:00
parent 4f401ac2b6
commit 82aa68097b
2 changed files with 11 additions and 1 deletions

View file

@ -165,6 +165,11 @@ func (s *session) wsToClient(msg []byte) error {
return err
}
// if profile change is the reason for disconnect, it's a kick event
if request.Message == "profile changed" {
request.Message = "kicked"
}
return s.toClient(&oldMessage.SystemMessage{
Event: oldEvent.SYSTEM_DISCONNECT,
Message: request.Message,

View file

@ -47,7 +47,12 @@ func (session *SessionCtx) profileChanged() {
}
if (!session.profile.CanConnect || !session.profile.CanLogin || !session.profile.CanWatch) && session.state.IsWatching {
// TODO: Needed for legacy implementation. Websocket must die before webrtc and deliver signal close message
// otherwise webrtc destroy would trigger websocket reconnect. In case of kick event, webrtc destroy is called
// before websocket destroy that delivers the information about the kick.
time.AfterFunc(time.Second, func() {
session.GetWebRTCPeer().Destroy()
})
}
if (!session.profile.CanConnect || !session.profile.CanLogin) && session.state.IsConnected {