(message)
| 69 | @socketio.on('keystroke') |
| 70 | @monitor_auth |
| 71 | def on_keystroke(message): |
| 72 | logger.debug_sensitive('received keystroke message: %s', message) |
| 73 | try: |
| 74 | keystroke = keystroke_request.parse_keystroke(message) |
| 75 | except keystroke_request.Error as e: |
| 76 | logger.error_sensitive('Failed to parse keystroke request: %s', e) |
| 77 | return {'success': False} |
| 78 | try: |
| 79 | hid_keystroke = js_to_hid.convert(keystroke) |
| 80 | except js_to_hid.UnrecognizedKeyCodeError: |
| 81 | logger.warning_sensitive('Unrecognized key: %s (keycode=%s)', |
| 82 | keystroke.key, keystroke.code) |
| 83 | return {'success': False} |
| 84 | keyboard_path = env.KEYBOARD_PATH |
| 85 | try: |
| 86 | fake_keyboard.send_keystroke(keyboard_path, hid_keystroke) |
| 87 | except hid_write.WriteError as e: |
| 88 | logger.error_sensitive('Failed to write key: %s (keycode=%s). %s', |
| 89 | keystroke.key, keystroke.code, e) |
| 90 | return {'success': False} |
| 91 | return {'success': True} |
| 92 | |
| 93 | |
| 94 | @socketio.on('mouse-event') |
nothing calls this directly
no test coverage detected