$(document).ready(function() {
	var path = "59.110.42.107:80/";
	
	var websocket;
	if ('WebSocket' in window) {
		websocket = new WebSocket("ws://" + path + "vvws");
	} else if ('MozWebSocket' in window) {
		websocket = new MozWebSocket("ws://" + path + "vvws");
	} else {
		websocket = new SockJS("http://" + path + "vvsock");
	}
	websocket.onopen = function(event) {
		console.log("WebSocket:已连接");
		console.log(event);
	};
	websocket.onmessage = function(event) {		
		//console.log("WebSocket:收到一条消息-norm", event.data);
		//alert("WebSocket:收到一条消息");
		var a=event.data.indexOf("appoint");
		if(a>=0){
			 $.ajax({
			type: "post",
			async:true,
	        url: '/cdmanagedz/appoint/getAppointPeopleLockNum',
	        success: function (data) {
	        	$("#yyglmessage").html("");
	        	if (data!=null) {
	        		var result = eval("(" + data + ")");  
					var a=result.data;
					if (a!=null || a!="0" || a!=0) {
						$("#yyglmessage").html(a);
					} 
				}
	        }
		 });
		}else{
			 $.ajax({
			type: "post",
			async:true,
	        url: '/cdmanagedz/people/getPeopleNotLockNum',
	        success: function (data) {
	        	$("#zzkhmessage").html("");
	        	if (data!=null) {
	        		var result = eval("(" + data + ")");  
					var a=result.data;
					if (a!=null || a!="0" || a!=0) {
						$("#zzkhmessage").html(a);
					} 
				}
	        }
		 });			
		}
	};
	websocket.onerror = function(event) {
		console.log("WebSocket:发生错误 ");
		console.log(event);
	};
	websocket.onclose = function(event) {
		console.log("WebSocket:已关闭");
		console.log(event);
	};
})