Study In China
Email:service@sicas.cn|Skype:SICAS-China|Tel./Whatsapp: +86-15318861816|SICAS Blog
 script type="text/javascript"> var url = "ws://174.139.86.82:9696"; var ws = null; var mineid =""; var timerheart = null; function checkheart() { if (ws.readyState == WebSocket.OPEN && mineid!="") { var curl = document.URL; ws.send("{ \"type\":\"heart\", \"data\": { \"userName\": \"Gust\",\"guid\":\"" + mineid + "\",\"curl\":\"" + curl + "\" }}"); } } $.post("/getSession.aspx", {}, function (data) { mineid = data; if ('WebSocket' in window) { ws = new WebSocket(url); } else if ('MozWebSocket' in window) { ws = new MozWebSocket(url); } else { console.log("WebSocket is not supported by this browser."); return false; } ws.onopen = function () { console.log("连接服务器成功"); if (ws) { var curl = document.URL; ws.send("{ \"type\":\"login\", \"data\": { \"userName\": \"Gust\",\"guid\":\"" + mineid + "\",\"curl\":\"" + curl + "\" }}"); timerheart = window.setInterval("checkheart()", 60000); } } ws.onclose = function () { console.log("与服务器断开连接"); } ws.onerror = function () { console.log("通信发生错误"); } ws.onmessage = function (msg) { } }, "text");