mirror of
https://github.com/m1k1o/neko.git
synced 2024-07-24 14:40:50 +12:00
add new WS keyboard event
This commit is contained in:
@ -22,6 +22,7 @@ const (
|
||||
CONTROL_REQUESTING = "control/requesting"
|
||||
CONTROL_GIVE = "control/give"
|
||||
CONTROL_CLIPBOARD = "control/clipboard"
|
||||
CONTROL_KEYBOARD = "control/keyboard"
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -46,6 +46,11 @@ type Clipboard struct {
|
||||
Text string `json:"text"`
|
||||
}
|
||||
|
||||
type Keyboard struct {
|
||||
Event string `json:"event"`
|
||||
Layout string `json:"layout"`
|
||||
}
|
||||
|
||||
type Control struct {
|
||||
Event string `json:"event"`
|
||||
ID string `json:"id"`
|
||||
|
@ -119,3 +119,14 @@ func (h *MessageHandler) controlClipboard(id string, session types.Session, payl
|
||||
h.remote.WriteClipboard(payload.Text)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (h *MessageHandler) controlKeyboard(id string, session types.Session, payload *message.Keyboard) error {
|
||||
// check if session is host
|
||||
if !h.sessions.IsHost(id) {
|
||||
h.logger.Debug().Str("id", id).Msg("is not the host")
|
||||
return nil
|
||||
}
|
||||
|
||||
h.remote.SetKeyboard(payload.Layout)
|
||||
return nil
|
||||
}
|
||||
|
@ -93,6 +93,13 @@ func (h *MessageHandler) Message(id string, raw []byte) error {
|
||||
utils.Unmarshal(payload, raw, func() error {
|
||||
return h.controlClipboard(id, session, payload)
|
||||
}), "%s failed", header.Event)
|
||||
case event.CONTROL_KEYBOARD:
|
||||
payload := &message.Keyboard{}
|
||||
return errors.Wrapf(
|
||||
utils.Unmarshal(payload, raw, func() error {
|
||||
return h.controlKeyboard(id, session, payload)
|
||||
}), "%s failed", header.Event)
|
||||
|
||||
|
||||
// Chat Events
|
||||
case event.CHAT_MESSAGE:
|
||||
|
Reference in New Issue
Block a user