protected function setupChunking()
    {
        if (! $this->options['loadAllMembers']) {
            $this->logger->info('loadAllMembers option is disabled, not setting chunking up');

            return $this->ready();
        }

        $checkForChunks = function () {
            if ((count($this->largeGuilds) < 1) && (count($this->largeSent) < 1)) {
                $this->ready();

                return;
            }

            $chunks = array_chunk($this->largeGuilds, 50);
            $this->logger->debug('sending '.count($chunks).' chunks with '.count($this->largeGuilds).' large guilds overall');
            $this->largeSent   = array_merge($this->largeGuilds, $this->largeSent);
            $this->largeGuilds = [];

            $sendChunks = function () use (&$sendChunks, &$chunks) {
                $chunk = array_pop($chunks);

                if (is_null($chunk)) {
                    return;
                }

                $this->logger->debug('sending chunk with '.count($chunk).' large guilds');

                $payload = [
                    'op' => Op::OP_GUILD_MEMBER_CHUNK,
                    'd'  => [
                        'guild_id' => $chunk,
                        'query'    => '',
                        'limit'    => 0,
                    ],
                ];

                $this->send($payload);
                $this->loop->addTimer(1, $sendChunks);
            };

            $sendChunks();
        };

        $this->loop->addPeriodicTimer(5, $checkForChunks);
        $this->logger->info('set up chunking, checking for chunks every 5 seconds');
        $checkForChunks();
    }
protected function setupChunking()
    {
        if (! $this->options['loadAllMembers']) {
            $this->logger->info('loadAllMembers option is disabled, not setting chunking up');

            return $this->ready();
        }

        $checkForChunks = function () {
            if ((count($this->largeGuilds) < 1) && (count($this->largeSent) < 1)) {
                $this->ready();

                return;
            }

            $chunks = array_chunk($this->largeGuilds, 50);
            $this->logger->debug('sending '.count($chunks).' chunks with '.count($this->largeGuilds).' large guilds overall');
            $this->largeSent   = array_merge($this->largeGuilds, $this->largeSent);
            $this->largeGuilds = [];

            $sendChunks = function () use (&$sendChunks, &$chunks) {
                $chunk = array_pop($chunks);

                if (is_null($chunk)) {
                    return;
                }

                $this->logger->debug('sending chunk with '.count($chunk).' large guilds');

                $payload = [
                    'op' => Op::OP_GUILD_MEMBER_CHUNK,
                    'd'  => [
                        'guild_id' => $chunk,
                        'query'    => '',
                        'limit'    => 0,
                    ],
                ];

                $this->send($payload);
                $this->loop->addTimer(1, $sendChunks);
            };

            $sendChunks();
        };

        $this->loop->addPeriodicTimer(5, $checkForChunks);
        $this->logger->info('set up chunking, checking for chunks every 5 seconds');
        $checkForChunks();
    }
protected function setupChunking ( ) { if ( ! $ this -> options [ 'loadAllMembers' ] ) { $ this -> logger -> info ( 'loadAllMembers option is disabled, not setting chunking up' ) ; return $ this -> ready ( ) ; } $ checkForChunks = function ( ) { if ( ( count ( $ this -> largeGuilds ) < 1 ) && ( count ( $ this -> largeSent ) < 1 ) ) { $ this -> ready ( ) ; return ; } $ chunks = array_chunk ( $ this -> largeGuilds , 50 ) ; $ this -> logger -> debug ( 'sending ' . count ( $ chunks ) . ' chunks with ' . count ( $ this -> largeGuilds ) . ' large guilds overall' ) ; $ this -> largeSent = array_merge ( $ this -> largeGuilds , $ this -> largeSent ) ; $ this -> largeGuilds = [ ] ; $ sendChunks = function ( ) use ( & $ sendChunks , & $ chunks ) { $ chunk = array_pop ( $ chunks ) ; if ( is_null ( $ chunk ) ) { return ; } $ this -> logger -> debug ( 'sending chunk with ' . count ( $ chunk ) . ' large guilds' ) ; $ payload = [ 'op' => Op :: OP_GUILD_MEMBER_CHUNK , 'd' => [ 'guild_id' => $ chunk , 'query' => '' , 'limit' => 0 , ] , ] ; $ this -> send ( $ payload ) ; $ this -> loop -> addTimer ( 1 , $ sendChunks ) ; } ; $ sendChunks ( ) ; } ; $ this -> loop -> addPeriodicTimer ( 5 , $ checkForChunks ) ; $ this -> logger -> info ( 'set up chunking, checking for chunks every 5 seconds' ) ; $ checkForChunks ( ) ; }
Sets guild member chunking up.

@return void
Sets guild member chunking up .