diff --git a/internal/api/room/screen.go b/internal/api/room/screen.go index 67c658ef..9cc54b96 100644 --- a/internal/api/room/screen.go +++ b/internal/api/room/screen.go @@ -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) } diff --git a/internal/websocket/handler/screen.go b/internal/websocket/handler/screen.go index cce9f4ec..a526bc81 100644 --- a/internal/websocket/handler/screen.go +++ b/internal/websocket/handler/screen.go @@ -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 } diff --git a/internal/websocket/handler/system.go b/internal/websocket/handler/system.go index 86b55b9e..399453e2 100644 --- a/internal/websocket/handler/system.go +++ b/internal/websocket/handler/system.go @@ -40,13 +40,9 @@ func (h *MessageHandlerCtx) systemInit(session types.Session) error { session.Send( event.SYSTEM_INIT, message.SystemInit{ - SessionId: session.ID(), - ControlHost: controlHost, - ScreenSize: message.ScreenSize{ - Width: size.Width, - Height: size.Height, - Rate: size.Rate, - }, + SessionId: session.ID(), + ControlHost: controlHost, + ScreenSize: message.ScreenSize(*size), Sessions: sessions, ImplicitHosting: h.sessions.ImplicitHosting(), ScreencastEnabled: h.capture.Screencast().Enabled(),