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.HttpInternalServerError().WithInternalMsg("unable to get screen configuration")
} }
return utils.HttpSuccess(w, ScreenConfigurationPayload{ payload := ScreenConfigurationPayload(*size)
Width: size.Width, return utils.HttpSuccess(w, payload)
Height: size.Height,
Rate: size.Rate,
})
} }
func (h *RoomHandler) screenConfigurationChange(w http.ResponseWriter, r *http.Request) error { 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 return err
} }
if err := h.desktop.SetScreenSize(types.ScreenSize{ size := types.ScreenSize(*data)
Width: data.Width, if err := h.desktop.SetScreenSize(size); err != nil {
Height: data.Height,
Rate: data.Rate,
}); err != nil {
return utils.HttpUnprocessableEntity("cannot set screen size").WithInternalErr(err) return utils.HttpUnprocessableEntity("cannot set screen size").WithInternalErr(err)
} }
h.sessions.Broadcast( payload := message.ScreenSize(*data)
event.SCREEN_UPDATED, h.sessions.Broadcast(event.SCREEN_UPDATED, payload, nil)
message.ScreenSize{
Width: data.Width,
Height: data.Height,
Rate: data.Rate,
}, nil)
return utils.HttpSuccess(w, data) 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") return errors.New("is not the admin")
} }
if err := h.desktop.SetScreenSize(types.ScreenSize{ data := types.ScreenSize(*payload)
Width: payload.Width, if err := h.desktop.SetScreenSize(data); err != nil {
Height: payload.Height,
Rate: payload.Rate,
}); err != nil {
return err return err
} }
h.sessions.Broadcast( h.sessions.Broadcast(event.SCREEN_UPDATED, payload, nil)
event.SCREEN_UPDATED,
message.ScreenSize{
Width: payload.Width,
Height: payload.Height,
Rate: payload.Rate,
}, nil)
return nil return nil
} }

View File

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