57 lines
1.1 KiB
Go
Raw Normal View History

2020-11-01 16:09:48 +01:00
package handler
import (
2020-10-28 19:15:48 +01:00
"demodesk/neko/internal/types"
"demodesk/neko/internal/types/event"
"demodesk/neko/internal/types/message"
)
2020-11-01 16:09:48 +01:00
func (h *MessageHandlerCtx) controlRelease(session types.Session) error {
2021-08-29 18:23:58 +02:00
logger := h.logger.With().Str("session_id", session.ID()).Logger()
2021-03-14 00:45:51 +01:00
if !session.Profile().CanHost {
2021-08-29 18:23:58 +02:00
logger.Debug().Msg("is not allowed to host")
2020-12-06 18:50:41 +01:00
return nil
}
2020-10-31 23:03:37 +01:00
if !session.IsHost() {
2021-08-29 18:23:58 +02:00
logger.Debug().Msg("is not the host")
return nil
}
2020-12-02 10:46:00 +01:00
h.desktop.ResetKeys()
h.sessions.ClearHost()
2020-12-02 10:46:00 +01:00
2020-11-18 20:30:33 +01:00
return nil
}
2020-11-01 16:09:48 +01:00
func (h *MessageHandlerCtx) controlRequest(session types.Session) error {
2021-08-29 18:23:58 +02:00
logger := h.logger.With().Str("session_id", session.ID()).Logger()
2021-03-14 00:45:51 +01:00
if !session.Profile().CanHost {
2021-08-29 18:23:58 +02:00
logger.Debug().Msg("is not allowed to host")
2020-12-06 18:50:41 +01:00
return nil
}
2020-12-02 10:47:20 +01:00
if session.IsHost() {
2021-08-29 18:23:58 +02:00
logger.Debug().Msg("is already the host")
2020-12-02 10:47:20 +01:00
return nil
}
2020-12-02 11:24:20 +01:00
if !h.sessions.ImplicitHosting() {
// tell session if there is a host
if host := h.sessions.GetHost(); host != nil {
return session.Send(
message.ControlHost{
Event: event.CONTROL_HOST,
HasHost: true,
HostID: host.ID(),
})
}
}
2020-11-30 18:24:38 +01:00
h.sessions.SetHost(session)
2020-11-18 20:30:33 +01:00
return nil
}