mirror of
https://github.com/m1k1o/neko.git
synced 2024-07-24 14:40:50 +12:00
77 lines
1.7 KiB
Go
77 lines
1.7 KiB
Go
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 {
|
|
h.logger.Debug().Msg("could not get screen size")
|
|
return nil
|
|
}
|
|
|
|
// TODO: Sessions.
|
|
members := map[string]message.MemberData{}
|
|
for _, session := range h.sessions.List() {
|
|
sessionId := session.ID()
|
|
members[sessionId] = message.MemberData{
|
|
ID: sessionId,
|
|
Profile: session.GetProfile(),
|
|
State: session.GetState(),
|
|
}
|
|
}
|
|
|
|
return session.Send(
|
|
message.SystemInit{
|
|
Event: event.SYSTEM_INIT,
|
|
// TODO: Session ID.
|
|
MemberId: session.ID(),
|
|
ControlHost: controlHost,
|
|
ScreenSize: message.ScreenSize{
|
|
Width: size.Width,
|
|
Height: size.Height,
|
|
Rate: size.Rate,
|
|
},
|
|
// TODO: Sessions.
|
|
Members: members,
|
|
ImplicitHosting: h.sessions.ImplicitHosting(),
|
|
})
|
|
}
|
|
|
|
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,
|
|
Rate: fps,
|
|
})
|
|
}
|
|
}
|
|
|
|
broadcast := h.capture.Broadcast()
|
|
return session.Send(
|
|
message.SystemAdmin{
|
|
Event: event.SYSTEM_ADMIN,
|
|
ScreenSizesList: screenSizesList,
|
|
BroadcastStatus: message.BroadcastStatus{
|
|
IsActive: broadcast.Started(),
|
|
URL: broadcast.Url(),
|
|
},
|
|
})
|
|
}
|