2020-12-01 08:07:19 +13:00
|
|
|
package handler
|
|
|
|
|
|
|
|
import (
|
|
|
|
"demodesk/neko/internal/types"
|
|
|
|
"demodesk/neko/internal/types/event"
|
|
|
|
"demodesk/neko/internal/types/message"
|
|
|
|
)
|
|
|
|
|
|
|
|
func (h *MessageHandlerCtx) systemInit(session types.Session) error {
|
|
|
|
host := h.sessions.GetHost()
|
|
|
|
|
|
|
|
controlHost := message.ControlHost{
|
|
|
|
HasHost: host != nil,
|
|
|
|
}
|
|
|
|
|
|
|
|
if controlHost.HasHost {
|
|
|
|
controlHost.HostID = host.ID()
|
|
|
|
}
|
|
|
|
|
|
|
|
size := h.desktop.GetScreenSize()
|
|
|
|
if size == nil {
|
2021-03-14 12:12:32 +13:00
|
|
|
h.logger.Warn().Msg("could not get screen size")
|
2020-12-01 08:07:19 +13:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2021-03-14 12:05:31 +13:00
|
|
|
sessions := map[string]message.SessionData{}
|
2021-03-14 09:11:48 +13:00
|
|
|
for _, session := range h.sessions.List() {
|
2021-03-14 11:32:10 +13:00
|
|
|
sessionId := session.ID()
|
2021-03-14 12:05:31 +13:00
|
|
|
sessions[sessionId] = message.SessionData{
|
2021-03-14 11:32:10 +13:00
|
|
|
ID: sessionId,
|
2021-03-14 12:45:51 +13:00
|
|
|
Profile: session.Profile(),
|
|
|
|
State: session.State(),
|
2020-12-02 10:56:08 +13:00
|
|
|
}
|
2020-12-01 08:07:19 +13:00
|
|
|
}
|
|
|
|
|
|
|
|
return session.Send(
|
|
|
|
message.SystemInit{
|
2021-03-14 13:05:00 +13:00
|
|
|
Event: event.SYSTEM_INIT,
|
2021-03-14 12:05:31 +13:00
|
|
|
SessionId: session.ID(),
|
2021-02-15 02:40:17 +13:00
|
|
|
ControlHost: controlHost,
|
|
|
|
ScreenSize: message.ScreenSize{
|
2020-12-01 08:07:19 +13:00
|
|
|
Width: size.Width,
|
|
|
|
Height: size.Height,
|
2021-01-16 05:30:19 +13:00
|
|
|
Rate: size.Rate,
|
2020-12-01 08:07:19 +13:00
|
|
|
},
|
2021-07-15 00:23:51 +12:00
|
|
|
Sessions: sessions,
|
|
|
|
ImplicitHosting: h.sessions.ImplicitHosting(),
|
|
|
|
ScreencastEnabled: h.capture.Screencast().Enabled(),
|
2021-05-01 02:05:07 +12:00
|
|
|
WebRTC: message.SystemWebRTC{
|
|
|
|
Videos: h.capture.VideoIDs(),
|
|
|
|
},
|
2020-12-01 08:07:19 +13:00
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
func (h *MessageHandlerCtx) systemAdmin(session types.Session) error {
|
|
|
|
screenSizesList := []message.ScreenSize{}
|
|
|
|
for _, size := range h.desktop.ScreenConfigurations() {
|
2021-03-16 22:53:03 +13:00
|
|
|
for _, rate := range size.Rates {
|
2020-12-01 08:07:19 +13:00
|
|
|
screenSizesList = append(screenSizesList, message.ScreenSize{
|
|
|
|
Width: size.Width,
|
|
|
|
Height: size.Height,
|
2021-03-16 22:53:03 +13:00
|
|
|
Rate: rate,
|
2020-12-01 08:07:19 +13:00
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-01-23 02:09:47 +13:00
|
|
|
broadcast := h.capture.Broadcast()
|
2020-12-01 08:07:19 +13:00
|
|
|
return session.Send(
|
|
|
|
message.SystemAdmin{
|
|
|
|
Event: event.SYSTEM_ADMIN,
|
|
|
|
ScreenSizesList: screenSizesList,
|
|
|
|
BroadcastStatus: message.BroadcastStatus{
|
2021-02-06 02:03:53 +13:00
|
|
|
IsActive: broadcast.Started(),
|
2021-01-23 02:09:47 +13:00
|
|
|
URL: broadcast.Url(),
|
2020-12-01 08:07:19 +13:00
|
|
|
},
|
|
|
|
})
|
|
|
|
}
|