瀏覽代碼

对接中台

huangxiaojing 3 年之前
父節點
當前提交
794532a762

+ 39 - 134
screenAndroid/WXdraw.js

@@ -26,7 +26,6 @@ var cardToken = parameters["cardToken"];
 cardToken = cardToken && cardToken.replace(/@/g,"=");
 form.cardIp = parameters["cardIp"];
 form.port = parameters["port"];
-form.sn = parameters["sn"];
 form.username = parameters["username"];
 form.userCardId = parameters["userCardId"];
 form.ip = parameters["ip"];
@@ -55,29 +54,18 @@ function doConnect() {
 	wsss.binaryType = 'arraybuffer';
 
 	wsss.onopen = function () {
-		var pings = {
-			"event": "getScreenStatus"
-		}
+		// 获取虚拟场景状态
+		var pings = { "type": "getVsStatus" }
 		wsss.send(JSON.stringify(pings));
 		var bitRate = {
 			"data": {
 				"bitRate": 1243000
 			},
-			"event": "bitRate"
+			"type": "bitRate"
 		}
 		wsss.send(JSON.stringify(bitRate))
 	};
-	wsss.onclose = function (evt) {
-		wsss.close();
-		throttle(doConnect,100);
-		if(errorTime > 1000){
-			wx.miniProgram.switchTab({
-				url: '/pages/home/home'
-			})
-		}
-	};
 	wsss.onerror = function (evt) {
-		console.log(evt);
 		wsss.close();
 		throttle(doConnect,100);
 		if(errorTime > 1000){
@@ -108,11 +96,11 @@ $(".upload").on("click", function () {
 $(".botmat1img").on("click", function () {
 	var codes = $(this).attr("data-text")
 	if (codes == "home") {
-		wsss.send(ExexuteKeyBoard(3), form.sn);
+		wsss.send(ExexuteKeyBoard(3));
 	} else if (codes == "return") {
-		wsss.send(ExexuteKeyBoard(4), form.sn);
+		wsss.send(ExexuteKeyBoard(4));
 	} else if (codes == "gengduo") {
-		wsss.send(ExexuteKeyBoard(187), form.sn);
+		wsss.send(ExexuteKeyBoard(187));
 	}
 
 })
@@ -124,11 +112,11 @@ $(".PictureQuality").on("click", function () {
 		"data": {
 			"bitRate": id
 		},
-		"event": "bitRate"
+		"type": "bitRate"
 	}
 	wsss.send(JSON.stringify(bitRate))
 })
-
+var ongoingTouches = [];
 //画图形
 var draw_graph = function (graphType, obj) {
 	//把蒙版放于画板上面
@@ -143,87 +131,33 @@ var draw_graph = function (graphType, obj) {
 		$(".leftmains").css({
 			"right": "-4rem"
 		})
-		var touchfor = e.originalEvent.targetTouches; //for 的手指数组
-
+		var touchfor = e.originalEvent.changedTouches[0]; //for 的手指数组
+		ongoingTouches.push(touchfor);
+		var acrossWidthX = touchfor.pageY * (1280 / voheight);
+		var acrossHeightY = 720 - touchfor.pageX * (720 / vowidth);
+		var verticalWidthX = touchfor.pageX * (720 / vowidth);
+		var verticalHeightY = touchfor.pageY * (1280 / voheight);
 		//是否横屏
-		if (resolving == 0) {
-			var ping;
-			for (var i = 0; i < touchfor.length; i++) {
-				var cawidthXs = touchfor[i].pageY * (1280 / voheight)
-				var caheightYs = 720 - touchfor[i].pageX * (720 / vowidth)
-				ping = {
-					"data": {
-						"action": 0,
-						"count": touchfor.length,
-						"pointerId": i,
-						"x": cawidthXs.toFixed(2),
-						"y": caheightYs.toFixed(2)
-					},
-					"event": "0"
-				}
-			}
-			wsss.send(JSON.stringify(ping))
-		} else {
-			var ping;
-			for (var i = 0; i < touchfor.length; i++) {
-				var cawidthXs = touchfor[i].pageX * (720 / vowidth)
-				var caheightYs = touchfor[i].pageY * (1280 / voheight)
-				ping = {
-					"data": {
-						"action": 0,
-						"count": touchfor.length,
-						"pointerId": i,
-						"x": cawidthXs.toFixed(2),
-						"y": caheightYs.toFixed(2)
-					},
-					"event": "0"
-				}
-
-			}
-			wsss.send(JSON.stringify(ping));
-		}
+		var ping = resolving == 0 ? 
+			{"data":{"action": 0, "count": ongoingTouches.length, "id": touchfor.identifier, "x": acrossWidthX.toFixed(2), "y": acrossHeightY.toFixed(2)},"type": "event"} :
+				{"data":{"action": 0, "count": ongoingTouches.length, "id": touchfor.identifier, "x": verticalWidthX.toFixed(2), "y": verticalHeightY.toFixed(2)},"type": "event"};
+		wsss.send(JSON.stringify(ping));
 		canDraw = true;
 	};
 
 	//鼠标离开 把蒙版canvas的图片生成到canvas中
 	var touchend = function (e) {
-		var touchfor = e.originalEvent.changedTouches; //for 的手指数组
-		//是否横屏 morePortionUp
-		if (resolving == 0) {
-			var ping;
-			for (var i = 0; i < touchfor.length; i++) {
-				var cawidthXs = touchfor[i].pageY * (1280 / voheight);
-				var caheightYs = 720 - touchfor[i].pageX * (720 / vowidth);
-				ping = {
-					"data": {
-						"action": 1,
-						"count": touchfor.length,
-						"pointerId": i,
-						"x": cawidthXs.toFixed(2),
-						"y": caheightYs.toFixed(2)
-					},
-					"event": "1"
-				}
-			}
-			wsss.send(JSON.stringify(ping));
-		} else {
-			var ping;
-			for (var i = 0; i < touchfor.length; i++) {
-				var cawidthXs = touchfor[i].pageX * (720 / vowidth);
-				var caheightYs = touchfor[i].pageY * (1280 / voheight);
-				ping = {
-					"data": {
-						"action": 1,
-						"count": touchfor.length,
-						"pointerId": i,
-						"x": cawidthXs.toFixed(2),
-						"y": caheightYs.toFixed(2)
-					},
-					"event": "1"
-				}
-			}
-			wsss.send(JSON.stringify(ping))
-		}
+		var touchfor = e.originalEvent.changedTouches[0]; //for 的手指数组
+		var acrossWidthX = touchfor.pageY * (1280 / voheight);
+		var acrossHeightY = 720 - touchfor.pageX * (720 / vowidth);
+		var verticalWidthX = touchfor.pageX * (720 / vowidth);
+		var verticalHeightY = touchfor.pageY * (1280 / voheight);
+		//是否横屏
+		var ping = resolving == 0 ? 
+			{"data":{"action": 1, "count": ongoingTouches.length, "id": touchfor.identifier, "x": acrossWidthX.toFixed(2), "y": acrossHeightY.toFixed(2)},"type": "event"} :
+				{"data":{"action": 1, "count": ongoingTouches.length, "id": touchfor.identifier, "x": verticalWidthX.toFixed(2), "y": verticalHeightY.toFixed(2)},"type": "event"};
+		wsss.send(JSON.stringify(ping));
+		ongoingTouches.splice(touchfor.identifier, 1);
 		canDraw = false;
 	};
 
@@ -235,44 +169,15 @@ var draw_graph = function (graphType, obj) {
 	// 鼠标移动
 	var touchmove = function (e) {
 		e = e || window.event;
-		var touchfor = e.originalEvent.targetTouches; //for 的手指数组
-		var ping;
-		//是否横屏  morePortionMove
-		if (resolving == 0) {
-			for (var i = 0; i < touchfor.length; i++) {
-				var cawidthXs = touchfor[i].pageY * (1280 / voheight)
-				var caheightYs = 720 - touchfor[i].pageX * (720 / vowidth)
-				ping = {
-					"data": {
-						"action": 2,
-						"count": touchfor.length,
-						"pointerId": i,
-						"x": cawidthXs.toFixed(2),
-						"y": caheightYs.toFixed(2)
-					},
-					"event": "2"
-				}
-
-			}
-			wsss.send(JSON.stringify(ping))
-		} else {
-			var ping;
-			for (var i = 0; i < touchfor.length; i++) {
-				var cawidthXs = touchfor[i].pageX * (720 / vowidth);
-				var caheightYs = touchfor[i].pageY * (1280 / voheight);
-				ping = {
-					"data": {
-						"action": 2,
-						"count": touchfor.length,
-						"pointerId": i,
-						"x": cawidthXs.toFixed(2),
-						"y": caheightYs.toFixed(2)
-					},
-					"event": "2"
-				}
-			}
-			wsss.send(JSON.stringify(ping));
-		};
+		var touchfor =  e.originalEvent.changedTouches[0]; //for 的手指数组
+		var acrossWidthX = touchfor.pageY * (1280 / voheight);
+		var acrossHeightY = 720 - touchfor.pageX * (720 / vowidth);
+		var verticalWidthX = touchfor.pageX * (720 / vowidth);
+		var verticalHeightY = touchfor.pageY * (1280 / voheight);
+		var ping = resolving == 0 ? 
+			{"data":{"action": 2, "count": ongoingTouches.length, "id": touchfor.identifier, "x": acrossWidthX.toFixed(2), "y": acrossHeightY.toFixed(2)},"type": "event"} :
+				{"data":{"action": 2, "count": ongoingTouches.length, "id": touchfor.identifier, "x": verticalWidthX.toFixed(2), "y": verticalHeightY.toFixed(2)},"type": "event"};
+		wsss.send(JSON.stringify(ping));
 	};
 
 	//鼠标离开区域以外 除了涂鸦 都清空
@@ -301,4 +206,4 @@ function GetRequest() {
 		}
 	}
 	return obj;
-}
+}

+ 36 - 75
screenAndroid/WXtrialInterface.html

@@ -194,31 +194,30 @@
 				}, delay);
 			};
 		}
+		var intervaler;
 		function doConnect() {
 			ws = new WebSocket(socketURL);
 			ws.binaryType = 'arraybuffer';
-
-			ws.onclose = function (e) {
-				ws.close();
-				throttle(doConnect, 100);
-				if (errorTime > 1000) {
-					wx.miniProgram.switchTab({
+			intervaler = setInterval(() => {
+        if (ws.readyState === 1) {
+          ws.send("ping");
+        } else {
+          wx.miniProgram.switchTab({
 						url: '/pages/home/home'
-					})
-				}
-			}
+					});
+        }
+      }, 3000);
 
 			ws.addEventListener('open', function (event) {
-				var verifyBuffer = VerifyCode(parameters['sn'], cardToken);
+				// sn只要长度满足17位随机数,不需要从后台获取
+				var verifyBuffer = VerifyCode('RK3923C1201900139', cardToken);
 				console.log("鉴权报文:" + PrintArry(verifyBuffer));
 				ws.send(verifyBuffer);
-				// ws.send(ConfigChannel("RK3923C1201900139"));
-				// var checkBuffer = GetScreenState();
-				// ws.send(checkBuffer);
 			});
 
 			ws.addEventListener('error', function (event) {
 				ws.close();
+				clearInterval(intervaler);
 				throttle(doConnect, 100);
 				if (errorTime > 1000) {
 					wx.miniProgram.switchTab({
@@ -228,7 +227,6 @@
 			});
 			ws.addEventListener('message', function (event) {
 				var data = ParseProto(event.data); //JAVA服务器转发
-				ws.send('ping');
 				if (isAudioPlay) {
 					$('.weui-mask_transparent').hide();
 					$('.weui-toast').hide();
@@ -340,17 +338,19 @@
 				if(input[23] == 0x5c){
 					console.log("收到消息:" + PrintArry(input));
 				
-					if(CheckVerifyCode(input))
-					{			
-						console.log("鉴权通过,配置通道");
-						ws.send(ConfigChannel(parameters['sn']));					
+					if(CheckVerifyCode(input)) {
+						ws.send(ConfigChannel('RK3923C1201900139'));					
 						var checkBuffer = GetScreenState();
 						ws.send(checkBuffer);
 					}
-					else
-					{
-						console.log("鉴权失败");
-						//ws.close();
+					else {
+						$.toast("音视频鉴权失败", "text");
+						clearInterval(intervaler);
+						ws.close();
+						wsss.close();
+						wx.miniProgram.switchTab({
+							url: '/pages/home/home'
+						});
 					}
 				}
 				if (input[23] == 0x05) { //横竖屏标识
@@ -398,48 +398,12 @@
 			return false;
 		}
 
-		var url = window.location.href;
+		var url = window.location.href; 
 		url = url.split('/');
 		var baseUrl = url[0] + '//' + url[2];
-		var baseUrl = 'http://per.cs.se.androidscloud.com';
 		var form = {};
-		$.ajax({
-			url: baseUrl + "/api/user/v1/config/download/isShow",
-			data: {},
-			type: 'get',
-			dataType: 'json',
-			success: function (data) {
-				if (data.data) {
-					$("#showsuss").show()
-				} else {
-					$("#showsuss").hide()
-				}
-			}
-		})
-
-		form.clientType = parameters['clientType'];
-		form.diskName = parameters['diskName'];
-		form.id = parameters['id'];
+		form.cardToken = parameters['cardToken'];
 		form.userCardId = parameters['userCardId'];
-
-		if (form.clientType == 1) {
-			form.cardIp = parameters['cardIp'];
-			form.port = parameters['port'];
-			form.sn = parameters['sn'];
-			form.demoTime = parameters['demoTime'];
-			form.id = parameters['id'];
-		} else if (form.clientType == 2) { //分享屏幕
-			$(".leftmains").css({
-				"right": "-4rem"
-			})
-			$('.leftmains').hide()
-			$('.bottommains').hide()
-			$('#btnMuted').hide()
-
-			form.id = parameters['id'];
-			form.ip = parameters['ip'];
-			form.userCardId = parameters['userCardId'];
-		}
 		function array_unique(arr) {
 			return arr.filter(function (e, i) {
 				return arr.indexOf(e) === i;
@@ -450,9 +414,8 @@
 			$('.box-shear-plate').empty();
 			$.ajax({
 				url: baseUrl + "/api/user/v1/shear/content",
-				data: {},
 				headers: {
-					'Authorization': form.id  //id
+					'Authorization': form.cardToken
 				},
 				type: 'get',
 				dataType: 'json',
@@ -490,7 +453,7 @@
 				$.ajax({
 					url: baseUrl + "/api/user/v1/shear/content?" + ids,
 					headers: {
-						'Authorization': form.id  //id
+						'Authorization': form.cardToken
 					},
 					type: 'DELETE',
 					dataType: 'json',
@@ -512,7 +475,7 @@
 					userCardId: form.userCardId
 				}),
 				headers: {
-					'Authorization': form.id  //id
+					'Authorization': form.cardToken
 				},
 				contentType: "application/json;charset=UTF-8",
 				type: 'post',
@@ -531,7 +494,7 @@
 			$.ajax({
 				url: baseUrl + "/api/user/v1/shear/content?ids=" + id,
 				headers: {
-					'Authorization': form.id  //id
+					'Authorization': form.cardToken
 				},
 				type: 'DELETE',
 				dataType: 'json',
@@ -621,14 +584,6 @@
 				});
 		}
 		var orientation = 0; //0 竖屏,1横屏
-		// document.body.addEventListener('touchmove', function (e) {
-		// 	e.preventDefault()
-		// }, {
-		// 	passive: false
-		// })
-
-		// //初始化一下就可以了
-		// var vConsole = new VConsole();
 
 		var btnMuted = document.querySelector("#btnMuted");
 		btnMuted && (function () {
@@ -785,9 +740,12 @@
 		})
 
 		$("#upload").on("click", function () {
+			clearInterval(intervaler);
+			ws.close();
+			wsss.close();
 			wx.miniProgram.switchTab({
 				url: '/pages/home/home'
-			})
+			});
 		})
 
 		function selectText(x) {
@@ -813,7 +771,10 @@
 			})
 			selectText(x);
 			document.execCommand("copy");
-
+		}
+		window.onbeforeunload = function() {
+			ws.close();
+			wsss.close();
 		}
 	</script>
 	<script type="text/javascript" src="aac.js"></script>

+ 9 - 16
screenAndroid/helper.js

@@ -58,10 +58,8 @@ function makeFrame(sn, dataType, jsonCmd) {
 }
 //触发键盘事件, code表示键盘值
 function ExexuteKeyDown(code) {
-	var jsonObj = { "data": { "keyCode": code, "event": "keyDown" } };
-	var json = JSON.stringify(jsonObj);
-	var sn = "RK3923C1201900139";
-	return json;
+	var jsonObj = { "data": { "keyCode": code }, "type": "keyCode" };
+	return JSON.stringify(jsonObj);
 }
 //触发鼠标按下事件,x:x坐标, y:y坐标
 function ExexuteMouseDown(x, y) {
@@ -79,10 +77,9 @@ function ExexuteMouseMove(x, y) {
 }
 
 function ExexuteKeyBoard(keycode) {
-	var jsonObj = { "data": { "keyCode": keycode.toString() }, "event": "keyCode" };
-	var json = JSON.stringify(jsonObj);
-	var sn = "RK3923C1201900139";
-	return json;
+	// 187:虚拟按键菜单键,3:虚拟按键home键,4:虚拟按键返回键,24:音量增大,25:音量减小
+	var jsonObj = { "data": { "keyCode": keycode.toString() }, "type": "keyCode" };
+	return JSON.stringify(jsonObj);
 }
 
 //触发鼠标抬起事件,x:x坐标, y:y坐标
@@ -171,15 +168,13 @@ function RequestIFrame() {
 
 
 //生成鉴权报文
-function VerifyCode(sn, code)
-{
+function VerifyCode(sn, code) {
 	var len = code.length + 1;
 	var codeBuffer = new TextEncoder("utf-8").encode(code);//获取字符串ascii码
 	var buffer = new Uint8Array(len);
 	buffer[0] = 0x04;
 	
-	for(i = 0;i < codeBuffer.length;i++)
-	{
+	for(var i = 0;i < codeBuffer.length;i++) {
 		buffer[i + 1] = codeBuffer[i];
 	}
 	
@@ -187,14 +182,12 @@ function VerifyCode(sn, code)
 }
 
 //检查鉴权报文
-function CheckVerifyCode(data)
-{
+function CheckVerifyCode(data) {
 	var dataLen = data.length - 26;
 	var body = data.slice(24, 24 + dataLen);
 	console.log("打印:" + PrintArry(body));
 	
-	if(body[3] == 0x03)
-	{
+	if(body[3] == 0x03) {
 		return true;
 	}
 	

+ 38 - 130
screenIos/WXdraw.js

@@ -54,27 +54,17 @@ function doConnect() {
 	wsss.binaryType = 'arraybuffer';
 
 	wsss.onopen = function () {
-		var pings = {
-			"event": "getScreenStatus"
-		}
+		// 获取虚拟场景状态
+		var pings = { "type": "getVsStatus" }
 		wsss.send(JSON.stringify(pings));
 		var bitRate = {
 			"data": {
 				"bitRate": 1243000
 			},
-			"event": "bitRate"
+			"type": "bitRate"
 		}
 		wsss.send(JSON.stringify(bitRate))
 	};
-	wsss.onclose = function () {
-		wsss.close();
-		throttle(doConnect, 100);
-		if (errorTime > 1000) {
-			wx.miniProgram.switchTab({
-				url: '/pages/home/home'
-			})
-		}
-	};
 	wsss.onerror = function () {
 		wsss.close();
 		throttle(doConnect, 100);
@@ -105,11 +95,11 @@ $(".upload").on("click", function () {
 $(".botmat1img").on("click", function () {
 	var codes = $(this).attr("data-text")
 	if (codes == "home") {
-		wsss.send(ExexuteKeyBoard(3, form.sn));
+		wsss.send(ExexuteKeyBoard(3));
 	} else if (codes == "return") {
-		wsss.send(ExexuteKeyBoard(4, form.sn));
+		wsss.send(ExexuteKeyBoard(4));
 	} else if (codes == "gengduo") {
-		wsss.send(ExexuteKeyBoard(187, form.sn));
+		wsss.send(ExexuteKeyBoard(187));
 	}
 })
 //高清控制
@@ -120,11 +110,12 @@ $(".PictureQuality").on("click", function () {
 		"data": {
 			"bitRate": id
 		},
-		"event": "bitRate"
+		"type": "bitRate"
 	}
 	wsss.send(JSON.stringify(bitRate))
 })
 var canDraw = false;
+var ongoingTouches = [];
 //画图形
 var draw_graph = function (graphType) {
 	//把蒙版放于画板上面
@@ -139,88 +130,33 @@ var draw_graph = function (graphType) {
 		$(".leftmains").css({
 			"right": "-4rem"
 		})
-		var touchfor = e.originalEvent.targetTouches; //for 的手指数组
+		var touchfor = e.originalEvent.changedTouches[0]; //for 的手指数组
+		ongoingTouches.push(touchfor);
+		var acrossWidthX = touchfor.pageY * (1280 / voheight);
+		var acrossHeightY = 720 - touchfor.pageX * (720 / vowidth);
+		var verticalWidthX = touchfor.pageX * (720 / vowidth);
+		var verticalHeightY = touchfor.pageY * (1280 / voheight);
 		//是否横屏
-		if (resolving == 0) {
-			var ping
-			for (var i = 0; i < touchfor.length; i++) {
-				var cawidthXs = touchfor[i].pageY * (1280 / voheight)
-				var caheightYs = 720 - touchfor[i].pageX * (720 / vowidth)
-				ping = {
-					"data": {
-						"action": 0,
-						"count": touchfor.length,
-						"pointerId": i,
-						"x": cawidthXs.toFixed(2),
-						"y": caheightYs.toFixed(2)
-					},
-					"event": "0"
-				}
-			}
-			wsss.send(JSON.stringify(ping))
-		} else {
-			var ping
-			for (var i = 0; i < touchfor.length; i++) {
-				var cawidthXs = touchfor[i].pageX * (720 / vowidth)
-				var caheightYs = touchfor[i].pageY * (1280 / voheight)
-				ping = {
-					"data": {
-						"action": 0,
-						"count": touchfor.length,
-						"pointerId": i,
-						"x": cawidthXs.toFixed(2),
-						"y": caheightYs.toFixed(2)
-					},
-					"event": "0"
-				}
-
-			}
-			wsss.send(JSON.stringify(ping))
-		}
-
+		var ping = resolving == 0 ? 
+			{"data":{"action": 0, "count": ongoingTouches.length, "id": touchfor.identifier, "x": acrossWidthX.toFixed(2), "y": acrossHeightY.toFixed(2)},"type": "event"} :
+				{"data":{"action": 0, "count": ongoingTouches.length, "id": touchfor.identifier, "x": verticalWidthX.toFixed(2), "y": verticalHeightY.toFixed(2)},"type": "event"};
+		wsss.send(JSON.stringify(ping));
 		canDraw = true;
-
 	};
 
 	//鼠标离开 把蒙版canvas的图片生成到canvas中
 	var touchend = function (e) {
-		var touchfor = e.originalEvent.changedTouches; //for 的手指数组
-		//是否横屏 morePortionUp
-		if (resolving == 0) {
-			var ping
-			for (var i = 0; i < touchfor.length; i++) {
-				var cawidthXs = touchfor[i].pageY * (1280 / voheight)
-				var caheightYs = 720 - touchfor[i].pageX * (720 / vowidth)
-				ping = {
-					"data": {
-						"action": 1,
-						"count": touchfor.length,
-						"pointerId": i,
-						"x": cawidthXs.toFixed(2),
-						"y": caheightYs.toFixed(2)
-					},
-					"event": "1"
-				}
-			}
-			wsss.send(JSON.stringify(ping))
-		} else {
-			var ping
-			for (var i = 0; i < touchfor.length; i++) {
-				var cawidthXs = touchfor[i].pageX * (720 / vowidth)
-				var caheightYs = touchfor[i].pageY * (1280 / voheight)
-				ping = {
-					"data": {
-						"action": 1,
-						"count": touchfor.length,
-						"pointerId": i,
-						"x": cawidthXs.toFixed(2),
-						"y": caheightYs.toFixed(2)
-					},
-					"event": "1"
-				}
-			}
-			wsss.send(JSON.stringify(ping))
-		}
+		var touchfor = e.originalEvent.changedTouches[0]; //for 的手指数组
+		var acrossWidthX = touchfor.pageY * (1280 / voheight);
+		var acrossHeightY = 720 - touchfor.pageX * (720 / vowidth);
+		var verticalWidthX = touchfor.pageX * (720 / vowidth);
+		var verticalHeightY = touchfor.pageY * (1280 / voheight);
+		//是否横屏
+		var ping = resolving == 0 ? 
+			{"data":{"action": 1, "count": ongoingTouches.length, "id": touchfor.identifier, "x": acrossWidthX.toFixed(2), "y": acrossHeightY.toFixed(2)},"type": "event"} :
+				{"data":{"action": 1, "count": ongoingTouches.length, "id": touchfor.identifier, "x": verticalWidthX.toFixed(2), "y": verticalHeightY.toFixed(2)},"type": "event"};
+		wsss.send(JSON.stringify(ping));
+		ongoingTouches.splice(touchfor.identifier, 1);
 		canDraw = false;
 	};
 
@@ -232,43 +168,15 @@ var draw_graph = function (graphType) {
 	// 鼠标移动
 	var touchmove = function (e) {
 		e = e || window.event;
-		var touchfor = e.originalEvent.targetTouches; //for 的手指数组
-		var ping
-		//是否横屏  morePortionMove
-		if (resolving == 0) {
-			for (var i = 0; i < touchfor.length; i++) {
-				var cawidthXs = touchfor[i].pageY * (1280 / voheight)
-				var caheightYs = 720 - touchfor[i].pageX * (720 / vowidth)
-				ping = {
-					"data": {
-						"action": 2,
-						"count": touchfor.length,
-						"pointerId": i,
-						"x": cawidthXs.toFixed(2),
-						"y": caheightYs.toFixed(2)
-					},
-					"event": "2"
-				}
-			}
-			wsss.send(JSON.stringify(ping))
-		} else {
-			var ping
-			for (var i = 0; i < touchfor.length; i++) {
-				var cawidthXs = touchfor[i].pageX * (720 / vowidth)
-				var caheightYs = touchfor[i].pageY * (1280 / voheight)
-				ping = {
-					"data": {
-						"action": 2,
-						"count": touchfor.length,
-						"pointerId": i,
-						"x": cawidthXs.toFixed(2),
-						"y": caheightYs.toFixed(2)
-					},
-					"event": "2"
-				}
-			}
-			wsss.send(JSON.stringify(ping))
-		}
+		var touchfor =  e.originalEvent.changedTouches[0]; //for 的手指数组
+		var acrossWidthX = touchfor.pageY * (1280 / voheight);
+		var acrossHeightY = 720 - touchfor.pageX * (720 / vowidth);
+		var verticalWidthX = touchfor.pageX * (720 / vowidth);
+		var verticalHeightY = touchfor.pageY * (1280 / voheight);
+		var ping = resolving == 0 ? 
+			{"data":{"action": 2, "count": ongoingTouches.length, "id": touchfor.identifier, "x": acrossWidthX.toFixed(2), "y": acrossHeightY.toFixed(2)},"type": "event"} :
+				{"data":{"action": 2, "count": ongoingTouches.length, "id": touchfor.identifier, "x": verticalWidthX.toFixed(2), "y": verticalHeightY.toFixed(2)},"type": "event"};
+		wsss.send(JSON.stringify(ping));
 	};
 
 	//鼠标离开区域以外 除了涂鸦 都清空

+ 35 - 45
screenIos/WXtrialInterface.html

@@ -212,47 +212,10 @@
 		url = url.split('/');
 		var baseUrl = url[0] + '//' + url[2];
 		var form = {};
-		// 审核
-		$.ajax({
-			url: baseUrl + "/api/user/v1/config/download/isShow",
-			data: {},
-			type: 'get',
-			dataType: 'json',
-			success: function (data) {
-				if (data.data) {
-					$("#showsuss").show()
-				} else {
-					$("#showsuss").hide()
-				}
-			}
-		})
 		var parameters = GetRequest();
-		form.clientType = parameters['clientType'];
 		form.userCardId = parameters['userCardId'];
-		form.id = parameters['id'];
-
-		if (form.clientType == 1) {
-			form.cardIp = parameters['cardIp'];
-			form.port = parameters['port'];
-			form.sn = parameters['sn'];
-			form.demoTime = parameters['demoTime'];
-			form.id = parameters['id'];
-		} else if (form.clientType == 2) { // 分享屏幕 
-			$(".leftmains").css({
-				"right": "-4rem"
-			})
-			$('.leftmains').hide()
-			$('.bottommains').hide()
-			$('#btnMuted').hide()
-			form.ip = parameters['ip'];
-		}
+		form.cardToken = parameters['cardToken'];
 		var orientation = 0; //0 竖屏,1横屏
-
-		// document.body.addEventListener('touchmove', function (e) {
-		// 	e.preventDefault();
-		// }, {
-		// 	passive: false
-		// })
 		function array_unique(arr) {
 			return arr.filter(function (e, i) {
 				return arr.indexOf(e) === i;
@@ -263,9 +226,8 @@
 			$('.box-shear-plate').empty();
 			$.ajax({
 				url: baseUrl + "/api/user/v1/shear/content",
-				data: {},
 				headers: {
-					'Authorization': form.id  //id
+					'Authorization': form.cardToken
 				},
 				type: 'get',
 				dataType: 'json',
@@ -303,7 +265,7 @@
 				$.ajax({
 					url: baseUrl + "/api/user/v1/shear/content?" + ids,
 					headers: {
-						'Authorization': form.id  //id
+						'Authorization': form.cardToken
 					},
 					type: 'DELETE',
 					dataType: 'json',
@@ -325,7 +287,7 @@
 					userCardId: form.userCardId
 				}),
 				headers: {
-					'Authorization': form.id  //id
+					'Authorization': form.cardToken
 				},
 				contentType: "application/json;charset=UTF-8",
 				type: 'post',
@@ -344,7 +306,7 @@
 			$.ajax({
 				url: baseUrl + "/api/user/v1/shear/content?ids=" + id,
 				headers: {
-					'Authorization': form.id  //id
+					'Authorization': form.cardToken
 				},
 				type: 'DELETE',
 				dataType: 'json',
@@ -594,6 +556,9 @@
 		})
 
 		$("#upload").on("click", function () {
+			decodeWoker.postMessage('close');
+			decodeWoker.terminate();	
+			webSocketWorker.terminate();
 			wx.miniProgram.switchTab({
 				url: '/pages/home/home'
 			})
@@ -708,7 +673,7 @@
 		}
 		var ip = parameters["ip"];
 		var appletPushAddress = parameters["appletPushAddress"];
-		var token = parameters["token"];
+		var token = parameters["cardToken"];
 		var webSocketWorker = new Worker('websocket.js?ip=' + ip + '&appletPushAddress=' + appletPushAddress + '&token=' + token);
 
 		webSocketWorker.onmessage = function (event) {
@@ -720,6 +685,22 @@
 				decodeWoker.postMessage(event.data);
 			}
 			if (input[0] == 0x68) {
+				if(input[23] == 0x5c){
+					if(CheckVerifyCode(input)) {
+						decodeWoker.postMessage(ConfigChannel('RK3923C1201900139'));					
+						var checkBuffer = GetScreenState();
+						decodeWoker.postMessage(checkBuffer);
+					}
+					else {
+						$.toast("音视频鉴权失败", "text");
+						decodeWoker.postMessage('close');
+						decodeWoker.terminate();
+						webSocketWorker.terminate();
+						wx.miniProgram.switchTab({
+							url: '/pages/home/home'
+						});
+					}
+				}
 				if (input[23] == 0x05) { //横竖屏标识
 					var state = CheckScreenDirection(input.slice(24, 24 + 8));
 
@@ -738,6 +719,9 @@
 				}
 			}
 			if (event.data === 'close') {
+				decodeWoker.postMessage('close');
+				decodeWoker.terminate();
+				webSocketWorker.terminate();
 				wx.miniProgram.switchTab({
 					url: '/pages/home/home'
 				})
@@ -757,7 +741,13 @@
 		var isDrag = false;
 
 		myVideo.onkeydown = function (event) {
-			ExexuteKeyDown(e.keyCode, form.sn);
+			ExexuteKeyDown(e.keyCode);
+		}
+		window.onbeforeunload = function() {
+			wsss.close();
+			decodeWoker.postMessage('close');
+			decodeWoker.terminate();
+			webSocketWorker.terminate();
 		}
 	</script>
 	<script type="text/javascript" src="aac.js"></script>

+ 1 - 1
screenIos/css/WXtrialInterface.css

@@ -331,7 +331,7 @@ html {
 	display: flex;
 	align-items: center;
 	justify-content: center;
-	background: url(../img/homebg.jpg) no-repeat;
+	background: url(../img/homebg.png) no-repeat;
 	background-size: 100% 100%;
 }
 

+ 20 - 13
screenIos/helper.js

@@ -57,15 +57,9 @@ function makeFrame(sn, dataType, jsonCmd) {
 	return outPut;
 }
 //触发键盘事件, code表示键盘值
-function ExexuteKeyDown(code, sn) {
-	var jsonObj = {
-		"data": {
-			"keyCode": code,
-			"event": "keyDown"
-		}
-	};
-	var json = JSON.stringify(jsonObj);
-	return makeFrame(sn, 0, json);
+function ExexuteKeyDown(code) {
+	var jsonObj = { "data": { "keyCode": code }, "type": "keyCode" };
+	return JSON.stringify(jsonObj);
 }
 //触发鼠标按下事件,x:x坐标, y:y坐标
 function ExexuteMouseDown(x, y, sn) {
@@ -100,10 +94,9 @@ function ExexuteMouseMove(x, y, sn) {
 }
 
 function ExexuteKeyBoard(keycode) {
-	var jsonObj = { "data": { "keyCode": keycode.toString() }, "event": "keyCode" };
-	var json = JSON.stringify(jsonObj);
-	var sn = "RK3923C1201900139";
-	return json;
+	// 187:虚拟按键菜单键,3:虚拟按键home键,4:虚拟按键返回键,24:音量增大,25:音量减小
+	var jsonObj = { "data": { "keyCode": keycode.toString() }, "type": "keyCode" };
+	return JSON.stringify(jsonObj);
 }
 
 //触发鼠标抬起事件,x:x坐标, y:y坐标
@@ -235,3 +228,17 @@ function ConfigChannel(sn) {
 	var outPut = new Uint8Array([0x07]);
 	return makeFrameExtend(sn, 6, outPut);
 }
+
+//检查鉴权报文
+function CheckVerifyCode(data) {
+	var dataLen = data.length - 26;
+	var body = data.slice(24, 24 + dataLen);
+	console.log("打印:" + PrintArry(body));
+	
+	if(body[3] == 0x03)
+	{
+		return true;
+	}
+	
+	return false;
+}

+ 18 - 16
screenIos/websocket.js

@@ -2,12 +2,12 @@ self.importScripts("helper.js");
 var parameters = GetRequest();
 var ip = parameters["ip"];
 var appletPushAddress = parameters["appletPushAddress"];
-var cardToken = parameters["cardToken"];
+var cardToken = parameters["token"];
 cardToken = cardToken && cardToken.replace(/@/g,"=");
 var isWSS = true;
 var errorTime = 0;
 var socketURL = isWSS ? "wss://" + appletPushAddress + "?cardIp=" + ip + "&token=" + cardToken : "ws://" + appletPushAddress + "?cardIp=" + ip + "&token=" + cardToken;
-
+var intervaler;
 doConnect();
 
 function throttle(fn, delay) {
@@ -26,17 +26,18 @@ function throttle(fn, delay) {
 function doConnect() {
 	var ws = new WebSocket(socketURL);
 	ws.binaryType = 'arraybuffer';
-
-	ws.onclose = function () {
-		ws.close();
-		throttle(doConnect, 100);
-		if (errorTime > 1000) {
-			self.postMessage('close');
+	intervaler = setInterval(() => {
+		if (ws.readyState === 1) {
+			ws.send("ping");
+		} else {
+			wx.miniProgram.switchTab({
+				url: '/pages/home/home'
+			});
 		}
-	}
-
+	}, 3000);
 	ws.onerror = function () {
 		ws.close();
+		clearInterval(intervaler);
 		throttle(doConnect, 100);
 		if (errorTime > 1000) {
 			self.postMessage('close');
@@ -44,14 +45,12 @@ function doConnect() {
 	}
 
 	ws.addEventListener('open', function (event) {
-		ws.send(ConfigChannel("RK3923C1201900139"));
-		var checkBuffer = GetScreenState();
-		ws.send(checkBuffer);
+		var verifyBuffer = VerifyCode('RK3923C1201900139', cardToken);
+		ws.send(verifyBuffer);
 	});
 
 	ws.addEventListener('message', function (event) {
 		var input = new Uint8Array(event.data);
-		ws.send('ping');
 		if (input[0] == 0xff) {
 			self.postMessage(input);
 		} else {
@@ -60,8 +59,11 @@ function doConnect() {
 	});
 
 	self.addEventListener('message', function (e) {
-		ws.send(e.data);
-		ws.send('ping');
+		if (e === 'close') {
+			ws.close()
+		} else {
+			ws.send(e.data);
+		}
 	}, false);
 }