lint & logging fixes.

This commit is contained in:
Miroslav Šedivý 2021-03-16 10:53:03 +01:00
parent 58d029f455
commit a9aa62f062
7 changed files with 14 additions and 13 deletions

View File

@ -149,8 +149,10 @@ func (manager *MemberManagerCtx) Login(username string, password string) (types.
return nil, "", fmt.Errorf("session is already connected") return nil, "", fmt.Errorf("session is already connected")
} }
// delete existing session // TODO: Replace session.
manager.sessions.Delete(id) if err := manager.sessions.Delete(id); err != nil {
return nil, "", err
}
} }
return manager.sessions.Create(id, profile) return manager.sessions.Create(id, profile)

View File

@ -117,10 +117,7 @@ func (manager *SessionManagerCtx) Delete(id string) error {
return fmt.Errorf("Session id not found.") return fmt.Errorf("Session id not found.")
} }
if _, ok := manager.tokens[session.token]; ok { delete(manager.tokens, session.token)
delete(manager.tokens, session.token)
}
delete(manager.sessions, id) delete(manager.sessions, id)
manager.sessionsMu.Unlock() manager.sessionsMu.Unlock()

View File

@ -50,8 +50,8 @@ func (manager *WebSocketManagerCtx) fileChooserDialogEvents() {
ID: activeSession.ID(), ID: activeSession.ID(),
}); err != nil { }); err != nil {
manager.logger.Warn(). manager.logger.Warn().
Str("session_id", session.ID()).
Err(err). Err(err).
Str("session_id", session.ID()).
Msgf("could not send event `%s` to session", event.FILE_CHOOSER_DIALOG_OPENED) Msgf("could not send event `%s` to session", event.FILE_CHOOSER_DIALOG_OPENED)
} }
}) })

View File

@ -27,5 +27,6 @@ func (h *MessageHandlerCtx) keyboardModifiers(session types.Session, payload *me
NumLock: payload.NumLock, NumLock: payload.NumLock,
CapsLock: payload.CapsLock, CapsLock: payload.CapsLock,
}) })
return nil return nil
} }

View File

@ -29,5 +29,6 @@ func (h *MessageHandlerCtx) sendBroadcast(session types.Session, payload *messag
Subject: payload.Subject, Subject: payload.Subject,
Body: payload.Body, Body: payload.Body,
}, []string{session.ID()}) }, []string{session.ID()})
return nil return nil
} }

View File

@ -8,6 +8,7 @@ import (
func (h *MessageHandlerCtx) signalRequest(session types.Session) error { func (h *MessageHandlerCtx) signalRequest(session types.Session) error {
if !session.Profile().CanWatch { if !session.Profile().CanWatch {
h.logger.Debug().Str("session_id", session.ID()).Msg("not allowed to watch")
return nil return nil
} }
@ -33,7 +34,7 @@ func (h *MessageHandlerCtx) signalRequest(session types.Session) error {
func (h *MessageHandlerCtx) signalAnswer(session types.Session, payload *message.SignalAnswer) error { func (h *MessageHandlerCtx) signalAnswer(session types.Session, payload *message.SignalAnswer) error {
peer := session.GetWebRTCPeer() peer := session.GetWebRTCPeer()
if peer == nil { if peer == nil {
h.logger.Debug().Msg("webRTC peer does not exist") h.logger.Debug().Str("session_id", session.ID()).Msg("webRTC peer does not exist")
return nil return nil
} }
@ -43,7 +44,7 @@ func (h *MessageHandlerCtx) signalAnswer(session types.Session, payload *message
func (h *MessageHandlerCtx) signalCandidate(session types.Session, payload *message.SignalCandidate) error { func (h *MessageHandlerCtx) signalCandidate(session types.Session, payload *message.SignalCandidate) error {
peer := session.GetWebRTCPeer() peer := session.GetWebRTCPeer()
if peer == nil { if peer == nil {
h.logger.Debug().Msg("webRTC peer does not exist") h.logger.Debug().Str("session_id", session.ID()).Msg("webRTC peer does not exist")
return nil return nil
} }
@ -53,7 +54,7 @@ func (h *MessageHandlerCtx) signalCandidate(session types.Session, payload *mess
func (h *MessageHandlerCtx) signalVideo(session types.Session, payload *message.SignalVideo) error { func (h *MessageHandlerCtx) signalVideo(session types.Session, payload *message.SignalVideo) error {
peer := session.GetWebRTCPeer() peer := session.GetWebRTCPeer()
if peer == nil { if peer == nil {
h.logger.Debug().Msg("webRTC peer does not exist") h.logger.Debug().Str("session_id", session.ID()).Msg("webRTC peer does not exist")
return nil return nil
} }

View File

@ -23,7 +23,6 @@ func (h *MessageHandlerCtx) systemInit(session types.Session) error {
return nil return nil
} }
// TODO: Sessions.
sessions := map[string]message.SessionData{} sessions := map[string]message.SessionData{}
for _, session := range h.sessions.List() { for _, session := range h.sessions.List() {
sessionId := session.ID() sessionId := session.ID()
@ -52,11 +51,11 @@ func (h *MessageHandlerCtx) systemInit(session types.Session) error {
func (h *MessageHandlerCtx) systemAdmin(session types.Session) error { func (h *MessageHandlerCtx) systemAdmin(session types.Session) error {
screenSizesList := []message.ScreenSize{} screenSizesList := []message.ScreenSize{}
for _, size := range h.desktop.ScreenConfigurations() { for _, size := range h.desktop.ScreenConfigurations() {
for _, fps := range size.Rates { for _, rate := range size.Rates {
screenSizesList = append(screenSizesList, message.ScreenSize{ screenSizesList = append(screenSizesList, message.ScreenSize{
Width: size.Width, Width: size.Width,
Height: size.Height, Height: size.Height,
Rate: fps, Rate: rate,
}) })
} }
} }