Example usage for com.amazonaws.services.ec2.model GetConsoleScreenshotResult getImageData

List of usage examples for com.amazonaws.services.ec2.model GetConsoleScreenshotResult getImageData

Introduction

In this page you can find the example usage for com.amazonaws.services.ec2.model GetConsoleScreenshotResult getImageData.

Prototype


public String getImageData() 

Source Link

Document

The data that comprises the image.

Usage

From source file:ec2watch.EC2Watch.java

License:Open Source License

public void run() {

    ImageViewer viewer = null;//from w  w  w . j ava  2s.  c  o m
    AmazonEC2Client ec2Client = new AmazonEC2Client(clientConfiguration);

    if (region != null) {
        ec2Client.setRegion(Region.getRegion(Regions.fromName(region)));
    }

    while (true) {
        try {
            GetConsoleScreenshotResult result = ec2Client.getConsoleScreenshot(
                    new GetConsoleScreenshotRequest().withInstanceId(instanceId).withWakeUp(Boolean.TRUE));
            byte[] imageData = Base64.getDecoder().decode(result.getImageData());

            if (viewer == null) {
                viewer = new ImageViewer(instanceId, imageData);
            } else {
                viewer.setImageData(imageData);
                System.out.print(".");
            }

            Thread.sleep(interval * 1000);
        } catch (Exception e) {
            // Ignore it
            System.out.print("x");
        }

    }
}