【Java开源代码栏目提醒】:网学会员为广大网友收集整理了,AJAX_Desktop.java,希望对大家有所帮助!
package com.bam;
public class AJAX_Desktop {
/**
* @param args
*/
static int port = 80;
public static boolean log = false;
public static boolean loginfo = log && true;
public static boolean logdebug = log && true;
public static int refresh_milliseconds = 1500;
public static String extension = "png";
public static int width = 800;
public static int height = 600;
public static int chunks = 5;
public static void main(String args[]) {
System.out.println("Starting AJAX Remote Desktop Viewer...");
System.out.println("Command Line Options: ");
System.out.println(" -p:port port is the TCP/IP port the server will listen.");
System.out.println(" -c:chunks the screen will update using chunks*chunks refreshable squares");
System.out.println(" -r:refresh refresh is the milliseconds between AJAX calls");
System.out.println(" -w:width width in pixels of capture area, from top left corner.");
System.out.println(" -h:height height in pixels of capture area, from top left corner.");
System.out.println();
String arg = null;
for (int p=0; p < args.length; p++) {
arg = args[p];
if (arg.startsWith("-p:")) {
// 用户是否设置端口,如果没有,则使用缺省设置;
try {
port = Integer.parseInt(arg.substring(3));
} catch (Exception e) {
System.out.println("Invalid syntax for port, using default.");
}
if (port < 1 && port > 32000) port = 80;
} else if (arg.startsWith("-c:")) {
// 用户是否设置屏幕切割的块数
try {
chunks = Integer.parseInt(arg.substring(3));
} catch (Exception e) {
System.out.println("Invalid syntax for chunk size, using default.");
}
if (chunks < 1) chunks =1;
if (chunks > 100) chunks = 100;
} else if (arg.startsWith("-w:")) {
// 用户是否设置屏幕宽度
try {
width = Integer.parseInt(arg.substring(3));
} catch (Exception e) {
System.out.println("Invalid syntax for width, using default.");
}
if (width < 1) width =10;
if (width > 3200) width = 3200;
} else if (arg.startsWith("-h:")) {
// 用户是否设置屏幕高度
try {
height = Integer.parseInt(arg.substring(3));
} catch (Exception e) {
System.out.println("Invalid syntax for height, using default.");
}
if (height < 1) height =10;
if (height > 3200) height = 3200;
} else if (arg.startsWith("-r:")) {
try {
refresh_milliseconds = Integer.parseInt(arg.substring(3));
} catch (Exception e) {
System.out.println("Invalid syntax for refresh time, using default.");
}
if (refresh_milliseconds < 100) refresh_milliseconds = 100;
if (refresh_milliseconds > 1000000) refresh_milliseconds = 1000000;
}
}
System.out.println("Using " + width + "x" + height + " with " + chunks + "x" + chunks + " chunks on HTTP, port " + port + ".");
System.out.println("Default client refresh time set to " + refresh_milliseconds + " milliseconds.");
// 设置截取的屏幕
new ScreenCapture(width, height, chunks);
// 启动服务器
new AJAXServer(port, "Ajax Remote Desktop");
}
}