本文整理汇总了Java中pro.beam.interactive.robot.Robot类的典型用法代码示例。如果您正苦于以下问题:Java Robot类的具体用法?Java Robot怎么用?Java Robot使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Robot类属于pro.beam.interactive.robot包,在下文中一共展示了Robot类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: login
import pro.beam.interactive.robot.Robot; //导入依赖的package包/类
public static void login(String username, String oauthToken) throws ExecutionException, InterruptedException {
beam = new BeamAPI(oauthToken);
BeamUser user = beam.use(UsersService.class).getCurrent().get();
final Robot robot = new RobotBuilder().channel(user.channel).build(beam, false).get();
//Listen for report events on the robot.
robot.on(Protocol.Report.class, report -> {
for (Protocol.Report.TactileInfo tInfo : report.getTactileList()) {
KeyMap.getInstance().handleInput(tInfo, report.getUsers());
}
Protocol.ProgressUpdate pu = KeyMap.getInstance().getProgressUpdate();
try {
robot.write(pu);
} catch (IOException ex) {
System.err.println("Failed to send packet.");
ex.printStackTrace();
}
});
init();
}
示例2: getRobot
import pro.beam.interactive.robot.Robot; //导入依赖的package包/类
public ListenableFuture<Robot> getRobot(BeamAPI beam) {
RobotBuilder builder = new RobotBuilder();
builder.username(this.config.getString("beam.auth.username"));
builder.password(this.config.getString("beam.auth.password"));
builder.channel(this.config.getInt("beam.auth.channel"));
if (this.config.isSet("beam.auth.twoFactor")) {
builder.twoFactor(this.config.getString("beam.auth.twoFactor"));
}
return builder.build(beam);
}
示例3: main
import pro.beam.interactive.robot.Robot; //导入依赖的package包/类
public static void main(String[] args) {
// Construct an instance of the BeamAPI that will be used for communication with Tetris.
BeamAPI beam = new BeamAPI();
// This future will return a Robot that is connected. See usage below for how to add a callback to
// a ListenableFuture.
//
// A RobotBuilder is the entry-point to creating a Robot that you can do things with. It follows
// the typical builder-pattern as expressed in Java, and an example usage may be found below:
ListenableFuture<Robot> future = new RobotBuilder().username("<username>")
.password("<password>")
.channel(127)
.build(beam);
// This is a rudimentary example of how to listen for a callback on a ListenableFuture.
Futures.addCallback(future, new FutureCallback<Robot>() {
@Override public void onSuccess(Robot robot) {
// The robot is connected and ready to be used.
// Set up an event handler to listen to the Report message, and delegate
// into the given instance of a listener.
robot.on(Protocol.Report.class, new MouseMoveListener());
robot.on(Protocol.Report.class, new KeyPressListener());
}
@Override public void onFailure(Throwable throwable) {
// There was an error connecting to the socket.
System.err.println("Error experienced in connecting to Beam.");
throwable.printStackTrace();
}
});
}