国产+高潮+在线,国产 av 仑乱内谢,www国产亚洲精品久久,51国产偷自视频区视频,成人午夜精品网站在线观看

關(guān)于node的一個(gè)問題

大小老鬼

想用小程序和html建立通信,中間用node做服務(wù)器,在本地上以及部署好了,在服務(wù)器上就提示超時(shí),端口什么的都打開了,從本地到服務(wù)器的改動(dòng)只有改IP為域名和吧ws改為wss。想問一下該怎么解決?
程序如下

var ws = require("nodejs-websocket");
console.log("開始建立連接...")

var game1 = null,game2 = null , game1Ready = false , game2Ready = false;
var server  = ws.createServer(function(conn){
    conn.on("text", function (str) {
        console.log("收到:"+str)
        if(str==="game1"){
            game1 = conn;
            game1Ready = true;
            conn.sendText("success");
        }
        if(str==="game2"){
            game2 = conn;
            game2Ready = true;
        }

        if(game1Ready&&game2Ready){
            game2.sendText(str);
            game1.sendText(str);
        }

        conn.sendText(str)
    })
    conn.on("close", function (code, reason) {
        console.log("�ر�����")
    });
    conn.on("error", function (code, reason) {
        console.log("�쳣�ر�")
    });
}).listen(8080)
2622 1 0
1個(gè)回答

大小老鬼

這個(gè)是連接node的html的代碼

<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title></title>
    <style>

    </style>
</head>
<body>
    <div id="mess"></div>
    <button onclick="nihao()">hhhh</button>

    <script>
        var ws;

        function nihao(){
            ws.send("youmaobjj");
        }
        var mess = document.getElementById("mess");
        if(window.WebSocket){
            var ws = new WebSocket('wss://dxlg.giserhub.com:8080');
            ws.onopen = function(e){
                console.log("連接服務(wù)器成功");
                ws.send("game2");
            }
            ws.onclose = function(e){
                console.log("服務(wù)器關(guān)閉");
            }
            ws.onerror = function(){
                console.log("連接出錯(cuò)");
            }

            ws.onmessage = function(e){
               console.log(e.data)
            }
        }
    </script>
</body>
</html>
  • 暫無評(píng)論
年代過于久遠(yuǎn),無法發(fā)表回答
??