public function sendToAll(string $data, int $sender = 0, int $pageSize = 50): int
    {
        $startFd = 0;
        $count = 0;
        $fromUser = $sender < 1 ? 'SYSTEM' : $sender;
        $this->log("(broadcast)The #{$fromUser} send a message to all users. Data: {$data}");

        while (true) {
            $fdList = $this->server->connection_list($startFd, $pageSize);

            if ($fdList === false || ($num = \count($fdList)) === 0) {
                break;
            }

            $count += $num;
            $startFd = \end($fdList);

            /** @var $fdList array */
            foreach ($fdList as $fd) {
                $info = $this->getClientInfo($fd);

                if (isset($info['websocket_status']) && $info['websocket_status'] > 0) {
                    $this->server->push($fd, $data);
                }
            }
        }

        return $count;
    }
public function sendToAll(string $data, int $sender = 0, int $pageSize = 50): int
    {
        $startFd = 0;
        $count = 0;
        $fromUser = $sender < 1 ? 'SYSTEM' : $sender;
        $this->log("(broadcast)The #{$fromUser} send a message to all users. Data: {$data}");

        while (true) {
            $fdList = $this->server->connection_list($startFd, $pageSize);

            if ($fdList === false || ($num = \count($fdList)) === 0) {
                break;
            }

            $count += $num;
            $startFd = \end($fdList);

            /** @var $fdList array */
            foreach ($fdList as $fd) {
                $info = $this->getClientInfo($fd);

                if (isset($info['websocket_status']) && $info['websocket_status'] > 0) {
                    $this->server->push($fd, $data);
                }
            }
        }

        return $count;
    }
public function sendToAll ( string $ data , int $ sender = 0 , int $ pageSize = 50 ) : int { $ startFd = 0 ; $ count = 0 ; $ fromUser = $ sender < 1 ? 'SYSTEM' : $ sender ; $ this -> log ( "(broadcast)The #{$fromUser} send a message to all users. Data: {$data}" ) ; while ( true ) { $ fdList = $ this -> server -> connection_list ( $ startFd , $ pageSize ) ; if ( $ fdList === false || ( $ num = \ count ( $ fdList ) ) === 0 ) { break ; } $ count += $ num ; $ startFd = \ end ( $ fdList ) ; /** @var $fdList array */ foreach ( $ fdList as $ fd ) { $ info = $ this -> getClientInfo ( $ fd ) ; if ( isset ( $ info [ 'websocket_status' ] ) && $ info [ 'websocket_status' ] > 0 ) { $ this -> server -> push ( $ fd , $ data ) ; } } } return $ count ; }
send message to all connections
@param string $data
@param int $sender
@param int $pageSize
@return int
send message to all connections