<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>

                合規國際互聯網加速 OSASE為企業客戶提供高速穩定SD-WAN國際加速解決方案。 廣告
                ## 1 目錄結構 ~~~ Workerman/ ;Workerman內核代碼 Connection/ ;socket連接 ConnectionInterface.php ;socket連接接口 TcpConnecttion.php ;Tcp連接 AsyncTcpConnecttion.php ;異步Tcp連接 UdpConnection.php ;Udp連接 Events/ ;網絡事件庫 EventInterface.php ;網絡事件庫接口 Libevent.php ;Libevent網絡事件庫 Ev.php ;LivEv網絡事件庫 Select.php ;Select網絡事件庫 Lib/ ;類庫 Constants.php ;常量定義 Timer.php ;定時器 Protocols/ ProtocolInterface.php ;協議接口 Http mime.types ;mime類型 Http.php ;http協議 Text.php ;Text協議 Frame.php ;Frame協議 Websocket.php ;websocket協議 Worker.php ;Worker WebServer.php ;WebServer Autoloader.php ;自動加載器 ~~~ ## 2 主體流程 ~~~ <?php use Workerman\Worker; require_once '/your/path/Workerman/Autoloader.php'; $global_uid = 0; // 當客戶端連上來時分配uid,并保存連接,并通知所有客戶端 function handle_connection($connection) { global $text_worker, $global_uid; // 為這個鏈接分配一個uid $connection->uid = ++$global_uid; } // 當客戶端發送消息過來時,轉發給所有人 function handle_message($connection, $data) { global $text_worker; foreach($text_worker->connections as $conn) { $conn->send("user[{$connection->uid}] said: $data"); } } // 當客戶端斷開時,廣播給所有客戶端 function handle_close($connection) { global $text_worker; foreach($text_worker->connections as $conn) { $conn->send("user[{$connection->uid}] logout"); } } // 創建一個文本協議的Worker監聽2347接口 $text_worker = new Worker("text://0.0.0.0:2347"); // 只啟動1個進程,這樣方便客戶端之間傳輸數據 $text_worker->count = 1; $text_worker->onConnect = 'handle_connection'; $text_worker->onMessage = 'handle_message'; $text_worker->onClose = 'handle_close'; Worker::runAll(); ~~~ >[info] 1 創建worker處理對象 `$text_worker = new Worker("text://0.0.0.0:2347");` >[info] 2 設置啟動進程數目 `$text_worker->count = 1;` >[info] 3 注冊事件接口 ~~~ $text_worker->onConnect = 'handle_connection'; $text_worker->onMessage = 'handle_message'; $text_worker->onClose = 'handle_close'; ~~~ >[info] 4 啟動worker `Worker::runAll();`
                  <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>

                              哎呀哎呀视频在线观看