mirror of
https://github.com/m1k1o/neko.git
synced 2024-07-24 14:40:50 +12:00
unify types.ScreenSize and add ID to screen size update.
This commit is contained in:
parent
0f45aa3f19
commit
b90eb87c22
@ -11,24 +11,16 @@ import (
|
||||
"github.com/demodesk/neko/pkg/utils"
|
||||
)
|
||||
|
||||
type ScreenConfigurationPayload struct {
|
||||
Width int `json:"width"`
|
||||
Height int `json:"height"`
|
||||
Rate int16 `json:"rate"`
|
||||
}
|
||||
|
||||
func (h *RoomHandler) screenConfiguration(w http.ResponseWriter, r *http.Request) error {
|
||||
size := h.desktop.GetScreenSize()
|
||||
screenSize := h.desktop.GetScreenSize()
|
||||
|
||||
return utils.HttpSuccess(w, ScreenConfigurationPayload{
|
||||
Width: size.Width,
|
||||
Height: size.Height,
|
||||
Rate: size.Rate,
|
||||
})
|
||||
return utils.HttpSuccess(w, screenSize)
|
||||
}
|
||||
|
||||
func (h *RoomHandler) screenConfigurationChange(w http.ResponseWriter, r *http.Request) error {
|
||||
data := &ScreenConfigurationPayload{}
|
||||
auth, _ := auth.GetSession(r)
|
||||
|
||||
data := &types.ScreenSize{}
|
||||
if err := utils.HttpJsonRequest(w, r, data); err != nil {
|
||||
return err
|
||||
}
|
||||
@ -43,10 +35,9 @@ func (h *RoomHandler) screenConfigurationChange(w http.ResponseWriter, r *http.R
|
||||
return utils.HttpUnprocessableEntity("cannot set screen size").WithInternalErr(err)
|
||||
}
|
||||
|
||||
h.sessions.Broadcast(event.SCREEN_UPDATED, message.ScreenSize{
|
||||
Width: size.Width,
|
||||
Height: size.Height,
|
||||
Rate: size.Rate,
|
||||
h.sessions.Broadcast(event.SCREEN_UPDATED, message.ScreenSizeUpdate{
|
||||
ID: auth.ID(),
|
||||
ScreenSize: size,
|
||||
})
|
||||
|
||||
return utils.HttpSuccess(w, data)
|
||||
@ -56,16 +47,7 @@ func (h *RoomHandler) screenConfigurationChange(w http.ResponseWriter, r *http.R
|
||||
func (h *RoomHandler) screenConfigurationsList(w http.ResponseWriter, r *http.Request) error {
|
||||
configurations := h.desktop.ScreenConfigurations()
|
||||
|
||||
list := make([]ScreenConfigurationPayload, 0, len(configurations))
|
||||
for _, conf := range configurations {
|
||||
list = append(list, ScreenConfigurationPayload{
|
||||
Width: conf.Width,
|
||||
Height: conf.Height,
|
||||
Rate: conf.Rate,
|
||||
})
|
||||
}
|
||||
|
||||
return utils.HttpSuccess(w, list)
|
||||
return utils.HttpSuccess(w, configurations)
|
||||
}
|
||||
|
||||
func (h *RoomHandler) screenShotGet(w http.ResponseWriter, r *http.Request) error {
|
||||
|
@ -13,20 +13,14 @@ func (h *MessageHandlerCtx) screenSet(session types.Session, payload *message.Sc
|
||||
return errors.New("is not the admin")
|
||||
}
|
||||
|
||||
size, err := h.desktop.SetScreenSize(types.ScreenSize{
|
||||
Width: payload.Width,
|
||||
Height: payload.Height,
|
||||
Rate: payload.Rate,
|
||||
})
|
||||
|
||||
size, err := h.desktop.SetScreenSize(payload.ScreenSize)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
h.sessions.Broadcast(event.SCREEN_UPDATED, message.ScreenSize{
|
||||
Width: size.Width,
|
||||
Height: size.Height,
|
||||
Rate: size.Rate,
|
||||
h.sessions.Broadcast(event.SCREEN_UPDATED, message.ScreenSizeUpdate{
|
||||
ID: session.ID(),
|
||||
ScreenSize: size,
|
||||
})
|
||||
return nil
|
||||
}
|
||||
|
@ -22,13 +22,6 @@ func (h *MessageHandlerCtx) systemInit(session types.Session) error {
|
||||
HostID: hostID,
|
||||
}
|
||||
|
||||
size := h.desktop.GetScreenSize()
|
||||
screenSize := message.ScreenSize{
|
||||
Width: size.Width,
|
||||
Height: size.Height,
|
||||
Rate: size.Rate,
|
||||
}
|
||||
|
||||
sessions := map[string]message.SessionData{}
|
||||
for _, session := range h.sessions.List() {
|
||||
sessionId := session.ID()
|
||||
@ -44,7 +37,7 @@ func (h *MessageHandlerCtx) systemInit(session types.Session) error {
|
||||
message.SystemInit{
|
||||
SessionId: session.ID(),
|
||||
ControlHost: controlHost,
|
||||
ScreenSize: screenSize,
|
||||
ScreenSize: h.desktop.GetScreenSize(),
|
||||
Sessions: sessions,
|
||||
Settings: h.sessions.Settings(),
|
||||
TouchEvents: h.desktop.HasTouchSupport(),
|
||||
@ -60,9 +53,9 @@ func (h *MessageHandlerCtx) systemInit(session types.Session) error {
|
||||
func (h *MessageHandlerCtx) systemAdmin(session types.Session) error {
|
||||
configurations := h.desktop.ScreenConfigurations()
|
||||
|
||||
list := make([]message.ScreenSize, 0, len(configurations))
|
||||
list := make([]types.ScreenSize, 0, len(configurations))
|
||||
for _, conf := range configurations {
|
||||
list = append(list, message.ScreenSize{
|
||||
list = append(list, types.ScreenSize{
|
||||
Width: conf.Width,
|
||||
Height: conf.Height,
|
||||
Rate: conf.Rate,
|
||||
|
@ -15,9 +15,9 @@ type CursorImage struct {
|
||||
}
|
||||
|
||||
type ScreenSize struct {
|
||||
Width int
|
||||
Height int
|
||||
Rate int16
|
||||
Width int `json:"width"`
|
||||
Height int `json:"height"`
|
||||
Rate int16 `json:"rate"`
|
||||
}
|
||||
|
||||
func (s ScreenSize) String() string {
|
||||
|
@ -17,7 +17,7 @@ type SystemWebRTC struct {
|
||||
type SystemInit struct {
|
||||
SessionId string `json:"session_id"`
|
||||
ControlHost ControlHost `json:"control_host"`
|
||||
ScreenSize ScreenSize `json:"screen_size"`
|
||||
ScreenSize types.ScreenSize `json:"screen_size"`
|
||||
Sessions map[string]SessionData `json:"sessions"`
|
||||
Settings types.Settings `json:"settings"`
|
||||
TouchEvents bool `json:"touch_events"`
|
||||
@ -26,8 +26,8 @@ type SystemInit struct {
|
||||
}
|
||||
|
||||
type SystemAdmin struct {
|
||||
ScreenSizesList []ScreenSize `json:"screen_sizes_list"`
|
||||
BroadcastStatus BroadcastStatus `json:"broadcast_status"`
|
||||
ScreenSizesList []types.ScreenSize `json:"screen_sizes_list"`
|
||||
BroadcastStatus BroadcastStatus `json:"broadcast_status"`
|
||||
}
|
||||
|
||||
type SystemLogs = []SystemLog
|
||||
@ -151,9 +151,12 @@ type ControlTouch struct {
|
||||
/////////////////////////////
|
||||
|
||||
type ScreenSize struct {
|
||||
Width int `json:"width"`
|
||||
Height int `json:"height"`
|
||||
Rate int16 `json:"rate"`
|
||||
types.ScreenSize
|
||||
}
|
||||
|
||||
type ScreenSizeUpdate struct {
|
||||
ID string `json:"id"`
|
||||
types.ScreenSize
|
||||
}
|
||||
|
||||
/////////////////////////////
|
||||
|
Loading…
Reference in New Issue
Block a user