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"
|
2021-01-11 00:42:07 +13:00
|
|
|
"demodesk/neko/internal/utils"
|
2020-12-01 08:07:19 +13:00
|
|
|
)
|
|
|
|
|
|
|
|
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 {
|
|
|
|
h.logger.Debug().Msg("could not get screen size")
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2020-12-02 10:56:08 +13:00
|
|
|
members := map[string]message.MemberData{}
|
2020-12-01 08:07:19 +13:00
|
|
|
for _, session := range h.sessions.Members() {
|
2020-12-02 10:56:08 +13:00
|
|
|
members[session.ID()] = message.MemberData{
|
2020-12-04 04:10:52 +13:00
|
|
|
ID: session.ID(),
|
2020-12-09 03:37:48 +13:00
|
|
|
Profile: session.GetProfile(),
|
|
|
|
State: session.GetState(),
|
2020-12-02 10:56:08 +13:00
|
|
|
}
|
2020-12-01 08:07:19 +13:00
|
|
|
}
|
|
|
|
|
2021-01-11 00:42:07 +13:00
|
|
|
var cursorImage *message.CursorImage
|
|
|
|
cur := h.desktop.GetCursorImage()
|
|
|
|
uri, err := utils.GetCursorImageURI(cur)
|
|
|
|
if err == nil {
|
|
|
|
cursorImage = &message.CursorImage{
|
|
|
|
Event: event.CURSOR_IMAGE,
|
|
|
|
Uri: uri,
|
|
|
|
Width: cur.Width,
|
|
|
|
Height: cur.Height,
|
|
|
|
X: cur.Xhot,
|
|
|
|
Y: cur.Yhot,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-12-01 08:07:19 +13:00
|
|
|
return session.Send(
|
|
|
|
message.SystemInit{
|
2020-12-02 23:24:20 +13:00
|
|
|
Event: event.SYSTEM_INIT,
|
|
|
|
MemberId: session.ID(),
|
|
|
|
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
|
|
|
},
|
2020-12-02 23:24:20 +13:00
|
|
|
Members: members,
|
|
|
|
ImplicitHosting: h.sessions.ImplicitHosting(),
|
2021-01-11 00:42:07 +13:00
|
|
|
CursorImage: cursorImage,
|
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() {
|
|
|
|
for _, fps := range size.Rates {
|
|
|
|
screenSizesList = append(screenSizesList, message.ScreenSize{
|
|
|
|
Width: size.Width,
|
|
|
|
Height: size.Height,
|
2021-01-16 05:30:19 +13:00
|
|
|
Rate: fps,
|
2020-12-01 08:07:19 +13:00
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return session.Send(
|
|
|
|
message.SystemAdmin{
|
|
|
|
Event: event.SYSTEM_ADMIN,
|
|
|
|
ScreenSizesList: screenSizesList,
|
|
|
|
BroadcastStatus: message.BroadcastStatus{
|
|
|
|
IsActive: h.capture.BroadcastEnabled(),
|
|
|
|
URL: h.capture.BroadcastUrl(),
|
|
|
|
},
|
|
|
|
})
|
|
|
|
}
|