Browse Source

话务日志

miaofuhao 6 years ago
parent
commit
c64fe6f67e
1 changed files with 24 additions and 20 deletions
  1. 24 20
      CallCenterWeb.UI/js/main.js

+ 24 - 20
CallCenterWeb.UI/js/main.js

59
 			//打印日志
59
 			//打印日志
60
 			directType="recive";
60
 			directType="recive";
61
 			sendType=data.Type; //JSON.stringify(data)
61
 			sendType=data.Type; //JSON.stringify(data)
62
-			mesCont=JSON.stringify(data);
62
+			mesCont=JSON.stringify(evt);
63
 			debuggerLog()
63
 			debuggerLog()
64
 			if(data) {
64
 			if(data) {
65
 				var rlt = data.Result;
65
 				var rlt = data.Result;
150
 		//连接关闭的回调方法
150
 		//连接关闭的回调方法
151
 		ws.onclose = function(evt) {
151
 		ws.onclose = function(evt) {
152
 			//打印日志
152
 			//打印日志
153
-			//LogoutBack();
154
-			var data = JSON.parse(evt.data)[0];
153
+			LogoutBack();
155
 			directType="recive";
154
 			directType="recive";
156
 			sendType="close"; //JSON.stringify(data)
155
 			sendType="close"; //JSON.stringify(data)
157
-			mesCont=JSON.stringify(data);
156
+			mesCont=JSON.stringify(evt);
158
 			debuggerLog();
157
 			debuggerLog();
159
-			$(".hwzt").text('连接关闭!');
158
+			//$(".hwzt").text('连接关闭!');
160
 //			if(cls == 0) {
159
 //			if(cls == 0) {
161
 //				cls = 1;
160
 //				cls = 1;
162
 //				$(".hwzt").text('连接关闭!');
161
 //				$(".hwzt").text('连接关闭!');
163
 //				$("#top-search li i").removeClass("active");
162
 //				$("#top-search li i").removeClass("active");
164
-//				//reconnect();
163
+//				reconnect();
165
 //			}
164
 //			}
166
 		};
165
 		};
167
 		//连接发生错误的回调方法
166
 		//连接发生错误的回调方法
168
 		ws.onerror = function(evt) {
167
 		ws.onerror = function(evt) {
169
 			//产生异常
168
 			//产生异常
170
 			//打印日志
169
 			//打印日志
171
-			var data = JSON.parse(evt.data)[0];
170
+			//var data = JSON.parse(evt.data)[0];
172
 			directType="recive";
171
 			directType="recive";
173
 			sendType="连接错误 "; //JSON.stringify(data)
172
 			sendType="连接错误 "; //JSON.stringify(data)
174
-			mesCont=JSON.stringify(data);
173
+			mesCont=JSON.stringify(evt);
175
 			debuggerLog();
174
 			debuggerLog();
176
 			//LogoutBack();
175
 			//LogoutBack();
177
 			$(".hwzt").text('连接异常!');
176
 			$(".hwzt").text('连接异常!');
178
 			console.log(ws);
177
 			console.log(ws);
179
-//			if(ws == null || ws.readyState != ws.OPEN) {
180
-//				directType="send";
181
-//				sendType="开始重连 "; //JSON.stringify(data)
182
-//				mesCont=mesCont;
183
-//				debuggerLog()
184
-//				console.log(new Date() + "开始重连");
185
-//				reconnect();
186
-//				eorrorConnect=true
187
-//				$(".hwzt").text('连接异常!');
188
-//			}
189
-			$(".hwzt").text('连接异常!');
178
+			if(ws == null || ws.readyState != ws.OPEN) {
179
+				directType="send";
180
+				sendType="开始重连 "; //JSON.stringify(data)
181
+				mesCont=mesCont;
182
+				debuggerLog()
183
+				console.log(new Date() + "开始重连");
184
+				reconnect();
185
+				eorrorConnect=true
186
+			}
190
 		};
187
 		};
191
 	} catch(ex) {
188
 	} catch(ex) {
192
 		$(".hwzt").text('连接关闭 try-catch!');
189
 		$(".hwzt").text('连接关闭 try-catch!');
307
 
304
 
308
 //心跳检测
305
 //心跳检测
309
 var heartCheck = {
306
 var heartCheck = {
310
-	timeout: 25000, //25秒
307
+	timeout: 1000, //25秒
311
 	timeoutObj: null,
308
 	timeoutObj: null,
312
 	serverTimeoutObj: null,
309
 	serverTimeoutObj: null,
313
 	reset: function() {
310
 	reset: function() {
324
 			Send();
321
 			Send();
325
 			self.serverTimeoutObj = setTimeout(function() { //如果超过一定时间还没重置,说明后端主动断开了
322
 			self.serverTimeoutObj = setTimeout(function() { //如果超过一定时间还没重置,说明后端主动断开了
326
 				ws.close(); //如果onclose会执行reconnect,我们执行ws.close()就行了.如果直接执行reconnect 会触发onclose导致重连两次
323
 				ws.close(); //如果onclose会执行reconnect,我们执行ws.close()就行了.如果直接执行reconnect 会触发onclose导致重连两次
324
+				LogoutBack();
325
+				directType="recive";
326
+				sendType="close"; //JSON.stringify(data)
327
+				mesCont="心跳未收到";
328
+				debuggerLog();
329
+				//$(".hwzt").text('连接关闭!');
330
+				reconnect();
327
 			}, self.timeout)
331
 			}, self.timeout)
328
 		}, this.timeout)
332
 		}, this.timeout)
329
 	}
333
 	}