mirror of
https://github.com/m1k1o/neko.git
synced 2024-07-24 14:40:50 +12:00
new WS ControlRequest data type
This commit is contained in:
@ -51,6 +51,11 @@ type Control struct {
|
||||
ID string `json:"id"`
|
||||
}
|
||||
|
||||
type ControlRequest struct {
|
||||
Event string `json:"event"`
|
||||
KeyboardLayout string `json:"keyboard_layout"`
|
||||
}
|
||||
|
||||
type ControlTarget struct {
|
||||
Event string `json:"event"`
|
||||
ID string `json:"id"`
|
||||
|
@ -31,9 +31,12 @@ func (h *MessageHandler) controlRelease(id string, session types.Session) error
|
||||
return nil
|
||||
}
|
||||
|
||||
func (h *MessageHandler) controlRequest(id string, session types.Session) error {
|
||||
func (h *MessageHandler) controlRequest(id string, session types.Session, payload *message.ControlRequest) error {
|
||||
// check for host
|
||||
if !h.sessions.HasHost() {
|
||||
// TODO: Keyboard Layout change.
|
||||
h.logger.Warn().Msgf("should set keyboard to %s", payload.KeyboardLayout)
|
||||
|
||||
// set host
|
||||
h.sessions.SetHost(id)
|
||||
|
||||
|
@ -76,7 +76,11 @@ func (h *MessageHandler) Message(id string, raw []byte) error {
|
||||
case event.CONTROL_RELEASE:
|
||||
return errors.Wrapf(h.controlRelease(id, session), "%s failed", header.Event)
|
||||
case event.CONTROL_REQUEST:
|
||||
return errors.Wrapf(h.controlRequest(id, session), "%s failed", header.Event)
|
||||
payload := &message.ControlRequest{}
|
||||
return errors.Wrapf(
|
||||
utils.Unmarshal(payload, raw, func() error {
|
||||
return h.controlRequest(id, session, payload)
|
||||
}), "%s failed", header.Event)
|
||||
case event.CONTROL_GIVE:
|
||||
payload := &message.Control{}
|
||||
return errors.Wrapf(
|
||||
|
Reference in New Issue
Block a user