mirror of
https://github.com/m1k1o/neko.git
synced 2024-07-24 14:40:50 +12:00
port new API back to refactor.
This commit is contained in:
@ -26,7 +26,7 @@ func (a *ClipboardData) Render(w http.ResponseWriter, r *http.Request) error {
|
||||
|
||||
func (h *RoomHandler) ClipboardRead(w http.ResponseWriter, r *http.Request) {
|
||||
// TODO: error check?
|
||||
text := h.remote.ReadClipboard()
|
||||
text := h.desktop.ReadClipboard()
|
||||
|
||||
render.JSON(w, r, ClipboardData{
|
||||
Text: text,
|
||||
@ -41,7 +41,7 @@ func (h *RoomHandler) ClipboardWrite(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
// TODO: error check?
|
||||
h.remote.WriteClipboard(data.Text)
|
||||
h.desktop.WriteClipboard(data.Text)
|
||||
|
||||
w.WriteHeader(http.StatusNoContent)
|
||||
}
|
||||
|
@ -8,25 +8,22 @@ import (
|
||||
)
|
||||
|
||||
type RoomHandler struct {
|
||||
sessions types.SessionManager
|
||||
remote types.RemoteManager
|
||||
broadcast types.BroadcastManager
|
||||
websocket types.WebSocketHandler
|
||||
sessions types.SessionManager
|
||||
desktop types.DesktopManager
|
||||
capture types.CaptureManager
|
||||
}
|
||||
|
||||
func New(
|
||||
sessions types.SessionManager,
|
||||
remote types.RemoteManager,
|
||||
broadcast types.BroadcastManager,
|
||||
websocket types.WebSocketHandler,
|
||||
desktop types.DesktopManager,
|
||||
capture types.CaptureManager,
|
||||
) *RoomHandler {
|
||||
// Init
|
||||
|
||||
return &RoomHandler{
|
||||
sessions: sessions,
|
||||
remote: remote,
|
||||
broadcast: broadcast,
|
||||
websocket: websocket,
|
||||
sessions: sessions,
|
||||
desktop: desktop,
|
||||
capture: capture,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -6,7 +6,6 @@ import (
|
||||
"github.com/go-chi/render"
|
||||
|
||||
"demodesk/neko/internal/api/utils"
|
||||
"demodesk/neko/internal/websocket/broadcast"
|
||||
)
|
||||
|
||||
type ScreenConfiguration struct {
|
||||
@ -28,7 +27,7 @@ func (a *ScreenConfiguration) Render(w http.ResponseWriter, r *http.Request) err
|
||||
}
|
||||
|
||||
func (h *RoomHandler) ScreenConfiguration(w http.ResponseWriter, r *http.Request) {
|
||||
size := h.remote.GetScreenSize()
|
||||
size := h.desktop.GetScreenSize()
|
||||
|
||||
if size == nil {
|
||||
_ = render.Render(w, r, utils.ErrMessage(500, "Unable to get screen configuration."))
|
||||
@ -49,15 +48,12 @@ func (h *RoomHandler) ScreenConfigurationChange(w http.ResponseWriter, r *http.R
|
||||
return
|
||||
}
|
||||
|
||||
if err := h.remote.ChangeResolution(data.Width, data.Height, data.Rate); err != nil {
|
||||
if err := h.capture.ChangeResolution(data.Width, data.Height, data.Rate); err != nil {
|
||||
_ = render.Render(w, r, utils.ErrUnprocessableEntity(err))
|
||||
return
|
||||
}
|
||||
|
||||
if err := broadcast.ScreenConfiguration(h.sessions, "-todo-session-id-", data.Width, data.Height, data.Rate); err != nil {
|
||||
_ = render.Render(w, r, utils.ErrInternalServer(err))
|
||||
return
|
||||
}
|
||||
// TODO: Broadcast change to all sessions.
|
||||
|
||||
render.JSON(w, r, data)
|
||||
}
|
||||
@ -65,7 +61,7 @@ func (h *RoomHandler) ScreenConfigurationChange(w http.ResponseWriter, r *http.R
|
||||
func (h *RoomHandler) ScreenConfigurationsList(w http.ResponseWriter, r *http.Request) {
|
||||
list := []render.Renderer{}
|
||||
|
||||
ScreenConfigurations := h.remote.ScreenConfigurations()
|
||||
ScreenConfigurations := h.desktop.ScreenConfigurations()
|
||||
for _, size := range ScreenConfigurations {
|
||||
for _, fps := range size.Rates {
|
||||
list = append(list, &ScreenConfiguration{
|
||||
|
Reference in New Issue
Block a user