<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ??碼云GVP開源項目 12k star Uniapp+ElementUI 功能強大 支持多語言、二開方便! 廣告
                1.在/web/tool/demo/server下新建ws_server.php ``` <?php $server = new swoole_websocket_server("0.0.0.0", 9501); $server->set( [ 'enable_static_handler' => true, 'document_root' => "/web/tool/demo/server", ] ); //監聽websocket連接打開事件 $server->on('open', 'onOpen'); function onOpen($server, $request) { print_r($request->fd); } // 監聽ws消息事件 $server->on('message', function (swoole_websocket_server $server, $frame) { echo "接收 from {$frame->fd}:{$frame->data},opcode:{$frame->opcode},fin:{$frame->finish}\n"; $server->push($frame->fd, "singwa-push-secesss");//向客戶端推送數據 }); $server->on('close', function ($ser, $fd) { echo "client {$fd} 關閉\n"; }); $server->start(); ``` 2.新建/web/tool/demo/html/ws_client.html ``` <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title></title> </head> <body> <h1>singwa-swoole-ws測試<h1> <script> var wsUrl = "ws://xxxxxx.com:9501"; var websocket = new WebSocket(wsUrl); //實例對象的onopen屬性 websocket.onopen = function(evt) { websocket.send("hello");//向服務器發送數據,服務器才有回調 console.log("conected-swoole-success"); } // 實例化 onmessage websocket.onmessage = function(evt) { console.log("ws-server-return-data:" + evt.data); } //onclose websocket.onclose = function(evt) { console.log("close"); } //onerror websocket.onerror = function(evt, e) { console.log("error:" + evt.data); } </script> </body> </html> ``` 3.測試 ![](https://img.kancloud.cn/79/75/79755642f80ad308172b679cc1d75051_1326x466.png) ![](https://img.kancloud.cn/9b/82/9b82cbb2c1fb45327317dc686d8541ee_661x131.png)
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看