$(function() {
	
	

    var websocket;

    var url =$("#url_div").html();
    // 首先判断是否 支持 WebSocket
    if('WebSocket' in window) 
    {
        websocket = new WebSocket("wss"+url+"biz_pgw/websocket");
    } 
    else if('MozWebSocket' in window) 
    {
        websocket = new MozWebSocket("wss"+url+"biz_pgw/websocket");
    } 
    else 
    {
        websocket = new SockJS("wss"+url+"biz_pgw/sockjs/websocket");
    }

    // 打开时
    websocket.onopen = function(evnt) {
        console.log("  websocket.onopen  ");
    };

    // 处理消息时
    websocket.onmessage = function(evnt) {
    	
    	$("#msg-content").append(evnt.data);
		$("#msg-content").append("<br/><br/>");
    	
    };

    websocket.onerror = function(evnt) {
        console.log("  websocket.onerror  ");
    };

    websocket.onclose = function(evnt) {
        console.log("  websocket.onclose  ");
    };

});