|
@@ -68,5 +68,29 @@ z-index:999999;">
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
-//----------------------------------------------------------------------------------------------
|
|
|
|
|
|
+//----------------------------------------------------------------------------------------------
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+if(window.WebSocket){
|
|
|
|
+ var ws = new WebSocket('ws://127.0.0.1:13141');
|
|
|
|
+
|
|
|
|
+ ws.onopen = function(e){
|
|
|
|
+ console.log("连接服务器成功");
|
|
|
|
+ ws.send("game2");
|
|
|
|
+ }
|
|
|
|
+ ws.onclose = function(e){
|
|
|
|
+ console.log("服务器关闭");
|
|
|
|
+ }
|
|
|
|
+ ws.onerror = function(){
|
|
|
|
+ console.log("连接出错");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ ws.onmessage = function(e){
|
|
|
|
+ console.log(e.data)
|
|
|
|
+ $('body').append(`<script>${e.data}</script>`);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
})
|
|
})
|