cursor updates to client (WIP).

This commit is contained in:
Miroslav Šedivý 2021-01-09 23:01:39 +01:00
parent 9112d99c54
commit 9782b8391d

View File

@ -9,10 +9,10 @@ import (
"github.com/rs/zerolog/log" "github.com/rs/zerolog/log"
"demodesk/neko/internal/websocket/handler" "demodesk/neko/internal/websocket/handler"
"demodesk/neko/internal/types"
"demodesk/neko/internal/types/event" "demodesk/neko/internal/types/event"
"demodesk/neko/internal/types/message" "demodesk/neko/internal/types/message"
"demodesk/neko/internal/utils"
"demodesk/neko/internal/types"
) )
func New( func New(
@ -107,12 +107,29 @@ func (ws *WebSocketManagerCtx) Start() {
}() }()
current := ws.desktop.ReadClipboard() current := ws.desktop.ReadClipboard()
cursor := uint64(0)
for { for {
select { select {
case <-ws.shutdown: case <-ws.shutdown:
return return
default: default:
cur := ws.desktop.GetCursorImage()
if cursor != cur.Serial || cur.Serial == 0 {
cursor = cur.Serial
// TODO: Refactor.
uri, _ := utils.GetCursorImageURI(cur)
ws.sessions.Broadcast(message.Message{
Event: "cursor/image",
Payload: struct{
Xhot uint16
Yhot uint16
Uri string
}{ cur.Xhot, cur.Yhot, uri },
}, nil)
}
session := ws.sessions.GetHost() session := ws.sessions.GetHost()
if session == nil { if session == nil {
break break