screen size retype one struct.

This commit is contained in:
Miroslav Šedivý 2021-09-20 18:28:13 +02:00
parent 31eb743a5d
commit 51577ecff4
3 changed files with 12 additions and 37 deletions

View File

@ -23,11 +23,8 @@ func (h *RoomHandler) screenConfiguration(w http.ResponseWriter, r *http.Request
return utils.HttpInternalServerError().WithInternalMsg("unable to get screen configuration")
}
return utils.HttpSuccess(w, ScreenConfigurationPayload{
Width: size.Width,
Height: size.Height,
Rate: size.Rate,
})
payload := ScreenConfigurationPayload(*size)
return utils.HttpSuccess(w, payload)
}
func (h *RoomHandler) screenConfigurationChange(w http.ResponseWriter, r *http.Request) error {
@ -36,21 +33,13 @@ func (h *RoomHandler) screenConfigurationChange(w http.ResponseWriter, r *http.R
return err
}
if err := h.desktop.SetScreenSize(types.ScreenSize{
Width: data.Width,
Height: data.Height,
Rate: data.Rate,
}); err != nil {
size := types.ScreenSize(*data)
if err := h.desktop.SetScreenSize(size); err != nil {
return utils.HttpUnprocessableEntity("cannot set screen size").WithInternalErr(err)
}
h.sessions.Broadcast(
event.SCREEN_UPDATED,
message.ScreenSize{
Width: data.Width,
Height: data.Height,
Rate: data.Rate,
}, nil)
payload := message.ScreenSize(*data)
h.sessions.Broadcast(event.SCREEN_UPDATED, payload, nil)
return utils.HttpSuccess(w, data)
}

View File

@ -13,21 +13,11 @@ func (h *MessageHandlerCtx) screenSet(session types.Session, payload *message.Sc
return errors.New("is not the admin")
}
if err := h.desktop.SetScreenSize(types.ScreenSize{
Width: payload.Width,
Height: payload.Height,
Rate: payload.Rate,
}); err != nil {
data := types.ScreenSize(*payload)
if err := h.desktop.SetScreenSize(data); err != nil {
return err
}
h.sessions.Broadcast(
event.SCREEN_UPDATED,
message.ScreenSize{
Width: payload.Width,
Height: payload.Height,
Rate: payload.Rate,
}, nil)
h.sessions.Broadcast(event.SCREEN_UPDATED, payload, nil)
return nil
}

View File

@ -42,11 +42,7 @@ func (h *MessageHandlerCtx) systemInit(session types.Session) error {
message.SystemInit{
SessionId: session.ID(),
ControlHost: controlHost,
ScreenSize: message.ScreenSize{
Width: size.Width,
Height: size.Height,
Rate: size.Rate,
},
ScreenSize: message.ScreenSize(*size),
Sessions: sessions,
ImplicitHosting: h.sessions.ImplicitHosting(),
ScreencastEnabled: h.capture.Screencast().Enabled(),