From e17e2cb606900d1ede7551dba142b831a7f748c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miroslav=20=C5=A0ediv=C3=BD?= Date: Sun, 6 Dec 2020 18:55:24 +0100 Subject: [PATCH] + CanAccessClipboard. --- internal/websocket/handler/clipboard.go | 5 +++++ internal/websocket/manager.go | 7 +++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/internal/websocket/handler/clipboard.go b/internal/websocket/handler/clipboard.go index ee0e0f25..d30cca2d 100644 --- a/internal/websocket/handler/clipboard.go +++ b/internal/websocket/handler/clipboard.go @@ -6,6 +6,11 @@ import ( ) func (h *MessageHandlerCtx) clipboardSet(session types.Session, payload *message.ClipboardData) error { + if !session.CanAccessClipboard() { + h.logger.Debug().Str("id", session.ID()).Msg("cannot access clipboard") + return nil + } + if !session.IsHost() { h.logger.Debug().Str("id", session.ID()).Msg("is not the host") return nil diff --git a/internal/websocket/manager.go b/internal/websocket/manager.go index b0463359..92aef70b 100644 --- a/internal/websocket/manager.go +++ b/internal/websocket/manager.go @@ -121,6 +121,11 @@ func (ws *WebSocketManagerCtx) Start() { break } + current = text + if !session.CanAccessClipboard() { + break + } + if err := session.Send( message.ClipboardData{ Event: event.CLIPBOARD_UPDATED, @@ -128,8 +133,6 @@ func (ws *WebSocketManagerCtx) Start() { }); err != nil { ws.logger.Warn().Err(err).Msg("could not sync clipboard") } - - current = text } time.Sleep(100 * time.Millisecond)