INNER CODE UNIT · JavaScript
sendToBot
ob-f/OpenBot · controller/web-server/client/index.js:36
const sendToBot = (key) => {
if (!signedInUser?.email) {
console.error('Cannot send command: sign in with Google first (same account as robot app).')
return
}
const msg = JSON.parse(key)
const payload =
msg.driveCmd !== undefined
? {driveCmd: msg.driveCmd, roomId: signedInUser.email}
: {command: msg.command, roomId: signedInUser.email}
connection.send(JSON.stringify(payload))
}
const command = new Commands(sendToBot)
const remoteKeyboard = new RemoteKeyboard(command.getCommandHandler())
const onKeyPress = (key) => {
remoteKeyboard.processKey(key)