Skip to content

Commit

Permalink
处理问题
Browse files Browse the repository at this point in the history
  • Loading branch information
yinzn committed May 22, 2020
1 parent 722069a commit 9e193a3
Show file tree
Hide file tree
Showing 25 changed files with 919 additions and 1,720 deletions.
291 changes: 147 additions & 144 deletions yin-control/WebRoot/index.jsp
Original file line number Diff line number Diff line change
@@ -1,154 +1,157 @@
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@page import="com.yin.ycontrol.screenShotter.GuiCamera"%>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8" %>
<%@page import="com.yin.ycontrol.screenShotter.GuiCamera" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
String path = request.getContextPath();
String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>监控-支持HTML5的浏览器</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<script type="text/javascript" src="./js/jquery-1.4.4.min.js"></script>
</head>
<body>
<canvas id="myCanvas" width="<%=GuiCamera.getWidth()%>" height="<%=GuiCamera.getHeight()%>"></canvas>
</body>
<head>
<base href="<%=basePath%>">
<title>监控-支持HTML5的浏览器</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<script type="text/javascript" src="./js/jquery-1.4.4.min.js"></script>
</head>
<body>
<canvas id="myCanvas" width="<%=GuiCamera.getWidth()%>" height="<%=GuiCamera.getHeight()%>"></canvas>
</body>
<script>
//检查浏览器是否支持HTML5,不支持的话跳转到旧页面,比较费流量
var myCanvas = document.getElementById("myCanvas");
if (!myCanvas.getContext)
{
alert("你使用的浏览器比较老,不支持画布功能. 使用本工具远程控制时比较耗费流量,对网络环境要求高,画面不流畅. 建议更换支持HTML5的浏览器,推荐chrome!");
window.location.href="./old.jsp";
}
var c=document.getElementById("myCanvas");
var cxt=c.getContext("2d");
var now = new Date();
var exitTime = new Date();
var frame=0;//帧数
var lastframe=0;//最新帧数
function flash() {
//获取下一帧数
getFrame();
var img=new Image();
img.src="./ImageServlet?min="+frame+"&max="+lastframe;
frame=lastframe;
img.onload = function(){
cxt.drawImage(img,0,0);
delete img;
window.setTimeout(flash, 200);
};
}
flash();
function getFrame(){
$.ajax({
async:false,
type:"post",
url:"./ImageServlet?lastframe=1",
cache:false,
success: function(msg) {
lastframe = msg;
}
});
}
//以下是控制部分的代码
function mousePosition(ev){
if(ev.pageX || ev.pageY){
return {x:ev.pageX, y:ev.pageY};
}
return {
x:ev.clientX + document.body.scrollLeft - document.body.clientLeft,
y:ev.clientY + document.body.scrollTop - document.body.clientTop
};
}
var request;
function mouseMove(ev){
ev = ev || window.event;
var mousePos = mousePosition(ev);
createRequest();
var url = "ControlServlet?x="+mousePos.x+"&y="+mousePos.y;
request.open("POST", url, true);
request.send(null);
}
document.onmousedown = function(ev){
ev = ev || window.event;
var mousePos = mousePosition(ev);
createRequest();
var url = "ControlServlet?x="+mousePos.x+"&y="+mousePos.y+"&e=mousedown";
request.open("POST", url, true);
request.send(null);
};
document.onmouseup = function(ev){
ev = ev || window.event;
var mousePos = mousePosition(ev);
createRequest();
var url = "ControlServlet?x="+mousePos.x+"&y="+mousePos.y+"&e=mouseup";
request.open("POST", url, true);
request.send(null);
};
document.oncontextmenu = function(ev){
ev = ev || window.event;
var mousePos = mousePosition(ev);
createRequest();
var url = "ControlServlet?x="+mousePos.x+"&y="+mousePos.y+"&e=rightclick";
request.open("POST", url, true);
request.send(null);
event.returnValue=false;
event.cancelBubble=true;
return false;
};
document.onkeydown = function(ev){
createRequest();
var url = "ControlServlet?k="+ev.keyCode+"&e=keydown";
request.open("POST", url, true);
request.send(null);
event.returnValue=false;
event.cancelBubble=true;
return false;
};
document.onkeyup = function(ev){
createRequest();
var url = "ControlServlet?k="+ev.keyCode+"&e=keyup";
request.open("POST", url, true);
request.send(null);
event.returnValue=false;
event.cancelBubble=true;
return false;
};
function createRequest() {
try {
request = new XMLHttpRequest();
} catch (trymicrosoft) {
try {
request = new ActiveXObject("Msxml2.XMLHTTP");
} catch (othermicrosoft) {
try {
request = new ActiveXObject("Microsoft.XMLHTTP");
} catch (failed) {
request = false;
}
//检查浏览器是否支持HTML5,不支持的话跳转到旧页面,比较费流量
var myCanvas = document.getElementById("myCanvas");
if (!myCanvas.getContext) {
alert("你使用的浏览器比较老,不支持画布功能. 使用本工具远程控制时比较耗费流量,对网络环境要求高,画面不流畅. 建议更换支持HTML5的浏览器,推荐chrome!");
window.location.href = "./old.jsp";
}
var c = document.getElementById("myCanvas");
var cxt = c.getContext("2d");
var now = new Date();
var exitTime = new Date();
var frame = 0;//帧数
var lastframe = 0;//最新帧数
function flash() {
//获取下一帧数
getFrame();
var img = new Image();
img.src = "./ImageServlet?min=" + frame + "&max=" + lastframe;
frame = lastframe;
img.onload = function () {
cxt.drawImage(img, 0, 0);
delete img;
window.setTimeout(flash, 200);
};
}
flash();
function getFrame() {
$.ajax({
async: false,
type: "post",
url: "./ImageServlet?lastframe=1",
cache: false,
success: function (msg) {
lastframe = msg;
}
});
}
//以下是控制部分的代码
function mousePosition(ev) {
if (ev.pageX || ev.pageY) {
return {x: ev.pageX, y: ev.pageY};
}
return {
x: ev.clientX + document.body.scrollLeft - document.body.clientLeft,
y: ev.clientY + document.body.scrollTop - document.body.clientTop
};
}
var request;
function mouseMove(ev) {
ev = ev || window.event;
var mousePos = mousePosition(ev);
createRequest();
var url = "ControlServlet?x=" + mousePos.x + "&y=" + mousePos.y;
request.open("POST", url, true);
request.send(null);
}
document.onmousedown = function (ev) {
ev = ev || window.event;
var mousePos = mousePosition(ev);
createRequest();
var url = "ControlServlet?x=" + mousePos.x + "&y=" + mousePos.y + "&e=mousedown";
request.open("POST", url, true);
request.send(null);
};
document.onmouseup = function (ev) {
ev = ev || window.event;
var mousePos = mousePosition(ev);
createRequest();
var url = "ControlServlet?x=" + mousePos.x + "&y=" + mousePos.y + "&e=mouseup";
request.open("POST", url, true);
request.send(null);
};
document.oncontextmenu = function (ev) {
ev = ev || window.event;
var mousePos = mousePosition(ev);
createRequest();
var url = "ControlServlet?x=" + mousePos.x + "&y=" + mousePos.y + "&e=rightclick";
request.open("POST", url, true);
request.send(null);
event.returnValue = false;
event.cancelBubble = true;
return false;
};
document.onkeydown = function (ev) {
createRequest();
var url = "ControlServlet?k=" + ev.keyCode + "&e=keydown";
request.open("POST", url, true);
request.send(null);
event.returnValue = false;
event.cancelBubble = true;
return false;
};
document.onkeyup = function (ev) {
createRequest();
var url = "ControlServlet?k=" + ev.keyCode + "&e=keyup";
request.open("POST", url, true);
request.send(null);
event.returnValue = false;
event.cancelBubble = true;
return false;
};
function createRequest() {
try {
request = new XMLHttpRequest();
} catch (trymicrosoft) {
try {
request = new ActiveXObject("Msxml2.XMLHTTP");
} catch (othermicrosoft) {
try {
request = new ActiveXObject("Microsoft.XMLHTTP");
} catch (failed) {
request = false;
}
}
}
if (!request)
alert("Error initializing XMLHttpRequest!");
}
}
if (!request)
alert("Error initializing XMLHttpRequest!");
}
</script>

</html>
26 changes: 7 additions & 19 deletions yin-control/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>6</java.version>
<maven.compiler.source>6</maven.compiler.source>
<maven.compiler.target>6</maven.compiler.target>
</properties>

<dependencies>
Expand All @@ -22,39 +25,24 @@
<scope>test</scope>
</dependency>
<dependency>
<groupId>repository.javax.mail</groupId>
<artifactId>mail</artifactId>
<version>1.4</version>
</dependency>
<dependency>
<groupId>repository.org.eclipse.jetty</groupId>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-server</artifactId>
<version>8.1.0.RC1</version>
</dependency>
<dependency>
<groupId>repository.org.eclipse.jetty</groupId>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-webapp</artifactId>
<version>8.1.0.RC1</version>
</dependency>
<dependency>
<groupId>repository.javax.servlet.jsp</groupId>
<groupId>javax.servlet.jsp</groupId>
<artifactId>jsp-api</artifactId>
<version>2.1</version>
</dependency>
<dependency>
<groupId>repository.org.glassfish.web</groupId>
<groupId>org.glassfish.web</groupId>
<artifactId>jsp-impl</artifactId>
<version>2.2</version>
</dependency>
<dependency>
<groupId>com.greenline.message</groupId>
<artifactId>greenline-message-service-share</artifactId>
<version>1.2</version>
</dependency>
<dependency>
<groupId>repository.com.caucho</groupId>
<artifactId>hessian</artifactId>
<version>4.0.7</version>
</dependency>
</dependencies>
</project>
34 changes: 17 additions & 17 deletions yin-control/src/main/java/com/yin/common/util/ConfigUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,23 @@

public final class ConfigUtil {

static Properties p = null;
static Properties p = null;

static void init() {
try {
InputStream in = ConfigUtil.class.getClassLoader()
.getResourceAsStream("config.properties");
p = new Properties();
p.load(in);
} catch (Exception e1) {
e1.printStackTrace();
}
}
public static String get(String key){
if(p==null){
init();
}
return p.getProperty(key);
static void init() {
try {
InputStream in = ConfigUtil.class.getClassLoader()
.getResourceAsStream("config.properties");
p = new Properties();
p.load(in);
} catch (Exception e1) {
e1.printStackTrace();
}
}
public static String get(String key){
if(p==null){
init();
}
return p.getProperty(key);

}
}
}
Loading

0 comments on commit 9e193a3

Please sign in to comment.