Last active
April 17, 2016 01:25
-
-
Save ProbablePrime/c4fa457358f8a454c0819757249d2437 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const Beam = require('beam-client-node'); | |
const Tetris = require('beam-interactive-node'); | |
const stream = 1234; | |
const username = 'connor'; | |
const password = 'password'; | |
const beam = new Beam(); | |
beam.use('password', { | |
username, | |
password | |
}).attempt().then(() => { | |
return beam.game.join(stream); | |
}).then(res => { | |
const details = { | |
remote: res.body.address, | |
channel: stream, | |
key: res.body.key | |
}; | |
const robot = new Tetris.Robot(details); | |
robot.handshake(err => { | |
if (err) { | |
throw new Error('Error connecting to Tetris', err); | |
} | |
}); | |
robot.on('report', report => { | |
console.log(report); | |
// Try console.log(report.tactile) | |
// console.log(report.joystick) | |
}); | |
}).catch(err => { | |
if (err.message !== undefined && err.message.body !== undefined) { | |
console.log(err); | |
} else { | |
throw err; | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment