huangxiaojing 4 anni fa
parent
commit
6dbc2580a0
2 ha cambiato i file con 84 aggiunte e 75 eliminazioni
  1. 47 50
      screenIos/WXdraw.js
  2. 37 25
      screenIos/websocket.js

+ 47 - 50
screenIos/WXdraw.js

@@ -100,51 +100,48 @@ var cUrl = "ws://192.168.198.82:9100/card?cardIp=" + data.ip
 // }
 console.log(cUrl, 'curl')
 // var cUrl = Number(data.clientType) === 3? "ws://"+urlss+"/authControlWebSocket?"+"clientType="+data.clientType+"&username="+data.username+"&userCardId="+data.userCardId : "ws://"+urlss+"/controlWebSocket?"+"clientType="+data.clientType+"&cardIp="+data.cardIp+"&port="+data.port+"&sn="+data.sn
-doConnect();
-function doConnect() {
-	var wsss = new WebSocket(cUrl);
-	wsss.binaryType = 'arraybuffer';
-	wsss.onopen = function () {
-		console.log("onopen==============");
-		var pings = {
-			"event": "getScreenStatus"
-		}
-		wsss.send(JSON.stringify(pings));
-		var bitRate = {
-			"data": {
-				"bitRate": 2243000
-			},
-			"event": "bitRate"
-		}
-		console.log('打开安卓卡wsss.onopen========', data.sn)
-		// wsss.send(JSON.stringify(bitRate));
-		wsss.send(ExexuteMove(JSON.stringify(bitRate), data.sn))
-	};
-	wsss.onmessage = function (event) {
-		// console.log("onMessage==============", event);
-		// var resets = JSON.parse(event.data)
-		// var resets = event.data;
-		// resets.errorMsg && alert(resets.errorMsg)
-		// resolving = resets.data.orientation
-		// if (resolving == 1) {} else {}
-		// console.log('>>>resolvingresolvingresolving', resolving)
-
-	};
-	wsss.onclose = function (event) {
-		alert("websocket连接断开");
-		doConnect();
-	};
-	wsss.onerror = function (event) {
-		console.log("onerror==============");
-	};
-}
-
-$('#box').on("click", function () {
+var wsss = new WebSocket(cUrl);
+console.log('wsssss==============', wsss)
+wsss.binaryType = 'arraybuffer';
+
+wsss.onopen = function() {
+	console.log("onopen==============");
+	var pings = {
+		"event": "getScreenStatus"
+	}
+	wsss.send(JSON.stringify(pings));
+	var bitRate = {
+		"data": {
+			"bitRate": 2243000
+		},
+		"event": "bitRate"
+	}
+	console.log('打开安卓卡wsss.onopen========', data.sn)
+	// wsss.send(JSON.stringify(bitRate));
+	wsss.send(ExexuteMove(JSON.stringify(bitRate), data.sn))
+};
+wsss.onmessage = function(event) {
+	// console.log("onMessage==============", event);
+	// var resets = JSON.parse(event.data)
+	// var resets = event.data;
+	// resets.errorMsg && alert(resets.errorMsg)
+	// resolving = resets.data.orientation
+	// if (resolving == 1) {} else {}
+	// console.log('>>>resolvingresolvingresolving', resolving)
+
+};
+wsss.onclose = function(event) {
+	console.log("onclose==============");
+};
+wsss.onerror = function(event) {
+	console.log("onerror==============");
+};
+$('#box').on("click", function() {
 
 	draw_graph('pencil', this)
 })
 //剪切板
-$(".upload").on("click", function () {
+$(".upload").on("click", function() {
 	let texts = $(this).attr("data-text")
 	if (texts == "uploads") {
 		$(".mainbox").css({
@@ -160,9 +157,9 @@ $(".upload").on("click", function () {
 })
 
 //home 控制home
-$(".botmat1img").on("click", function () {
+$(".botmat1img").on("click", function() {
 	let codes = $(this).attr("data-text")
-	console.log("homehomehome---------", codes)
+	console.log("homehomehome---------",codes)
 	if (codes == "home") {
 		// var bitRate = {
 		// 	"data": {
@@ -195,7 +192,7 @@ $(".botmat1img").on("click", function () {
 
 })
 //高清控制
-$(".PictureQuality").on("click", function () {
+$(".PictureQuality").on("click", function() {
 	$(this).addClass("avit").siblings().removeClass('avit')
 	let id = $(this).attr("data-id")
 	var bitRate = {
@@ -211,7 +208,7 @@ $(".PictureQuality").on("click", function () {
 })
 
 //画图形
-var draw_graph = function (graphType, obj) {
+var draw_graph = function(graphType, obj) {
 	console.log('111》》》', graphType)
 	//把蒙版放于画板上面
 	//$("#canvas_bak").css("z-index",1);
@@ -226,7 +223,7 @@ var draw_graph = function (graphType, obj) {
 	var startY;
 
 	//鼠标按下获取 开始xy开始画图
-	var touchstart = function (e) {
+	var touchstart = function(e) {
 		$('.control-right-img').attr({
 			"data-id": "2"
 		})
@@ -286,7 +283,7 @@ var draw_graph = function (graphType, obj) {
 	};
 
 	//鼠标离开 把蒙版canvas的图片生成到canvas中
-	var touchend = function (e) {
+	var touchend = function(e) {
 		var touchfor = e.originalEvent.changedTouches; //for 的手指数组
 		var touch = e.originalEvent.changedTouches[0];
 		var thochlethng = e.originalEvent.changedTouches.length
@@ -340,12 +337,12 @@ var draw_graph = function (graphType, obj) {
 	};
 
 	//清空层 云手机超出屏幕的开关
-	var clearContext = function (type) {
+	var clearContext = function(type) {
 		canDraw = false;
 	}
 
 	// 鼠标移动
-	var touchmove = function (e) {
+	var touchmove = function(e) {
 
 		e = e || window.event;
 		var touchfor = e.originalEvent.targetTouches; //for 的手指数组
@@ -407,7 +404,7 @@ var draw_graph = function (graphType, obj) {
 	};
 
 	//鼠标离开区域以外 除了涂鸦 都清空
-	var mouseout = function () {
+	var mouseout = function() {
 
 		if (graphType != 'handwriting') {
 			clearContext();

+ 37 - 25
screenIos/websocket.js

@@ -8,34 +8,46 @@ var socketURL = "ws://192.168.198.82:9100/card?cardIp=" + ip;
 // var socketURL = "ws://14.215.128.98:14102"
 // socketURL = "ws://127.0.0.1:8081"
 
+doConnect();
 
+function doConnect() {
+	var ws = new WebSocket(socketURL);
+	ws.binaryType = 'arraybuffer';
 
-var ws = new WebSocket(socketURL);
-ws.binaryType = 'arraybuffer';
-
-ws.addEventListener('open', function(event) {
-	console.log("发送配置帧");
-	// ws.send(ConfigChannel("RK3923C1201900139"));
-});
-
-self.addEventListener('message', function(e) {
-	// console.log("收到数据", e.data);
-	ws.send(e.data);
-	console.log('ws', ws)
-}, false);
-ws.addEventListener('message', function(event) {
-	//var objData = {type:0, data:input};
-	var input = new Uint8Array(event.data);
-
-	if (input[0] == 0xff) {
-		// console.log("1111111")
-		// decodeAAC(input);
-		self.postMessage(input);
-
-	} else {
-		self.postMessage(input);
+	ws.onclose = function (e) {
+		console.log('websocket 断开: ' + e.code + ' ' + e.reason + ' ' + e.wasClean);
+		console.log("时间: " + new Date() + e);
+		alert("websocket连接断开,准备重连");
+		doConnect();
 	}
-});
+
+	ws.addEventListener('open', function(event) {
+		console.log("发送配置帧");
+		// ws.send(ConfigChannel("RK3923C1201900139"));
+		ws.send(ConfigChannel("RK3923C1201900139"));
+		var buffer = RequestIFrame();
+		ws.send(buffer);
+	});
+
+	self.addEventListener('message', function(e) {
+		// console.log("收到数据", e.data);
+		ws.send(e.data);
+		console.log('ws', ws)
+	}, false);
+	ws.addEventListener('message', function(event) {
+		//var objData = {type:0, data:input};
+		var input = new Uint8Array(event.data);
+
+		if (input[0] == 0xff) {
+			// console.log("1111111")
+			// decodeAAC(input);
+			self.postMessage(input);
+
+		} else {
+			self.postMessage(input);
+		}
+	});
+}
 
 function GetRequest() {
   var url = location.search; // 获取url中"?"符后的字串