onRead
@return void
8707
protected function onRead()
    {
        start:
        if ($this->state === static::STATE_STANDBY) {
            if (($hdr = $this->readExact(2)) === false) {
                return; // not enough data
            }

            $u = unpack('S', $hdr);
            $this->responseCode = $u[1];
            $this->state = static::STATE_PACKET_HDR;
        }
        if ($this->state === static::STATE_PACKET_HDR) {
            if ($this->responseCode === static::REPL_KVAL) {
                $this->result = [];
                if (($hdr = $this->readExact(9)) === false) {
                    return; // not enough data
                }
                $this->encoding = Binary::getByte($hdr);
                $this->responseLength = Binary::getDword($hdr, true) - 4;
                $this->totalNum = Binary::getDword($hdr, true);
                $this->readedNum = 0;
                $this->state = static::STATE_PACKET_DATA;
            } else {
                if (($hdr = $this->lookExact(5)) === false) {
                    return; // not enough data
                }
                $this->encoding = Binary::getByte($hdr);
                $pl = Binary::getDword($hdr, true);
                if ($this->getInputLength() < 5 + $pl) {
                    return; // not enough data
                }
                $this->drain(5);
                $this->responseLength = $pl;
                if ($this->responseLength > $this->pool->maxAllowedPacket) {
                    $this->log('max-allowed-packet (' . $this->pool->config->maxallowedpacket->getHumanValue() . ') exceed, aborting connection');
                    $this->finish();
                    return;
                }
                if ($this->responseCode === static::REPL_ERR_NOT_FOUND) {
                    $this->drain($this->responseLength);
                    $this->result = null;
                    $this->isFinal = true;
                    $this->totalNum = 0;
                    $this->readedNum = 0;
                    $this->executeCb();
                } elseif ($this->responseCode === static::REPL_OK) {
                    $this->drain($this->responseLength);
                    $this->result = true;
                    $this->isFinal = true;
                    $this->totalNum = 0;
                    $this->readedNum = 0;
                    $this->executeCb();
                } elseif (($this->responseCode === static::REPL_ERR_MEM) ||
                    ($this->responseCode === static::REPL_ERR_NAN) ||
                    ($this->responseCode === static::REPL_ERR_LOCKED)
                ) {
                    $this->drain($this->responseLength);
                    $this->result = false;
                    $this->isFinal = true;
                    $this->totalNum = 0;
                    $this->readedNum = 0;
                    $this->executeCb();
                } else {
                    if ($this->responseCode === static::REPL_KVAL && $this->totalNum <= 0) {
                        $this->drain($this->responseLength);
                        $this->isFinal = true;
                        $this->totalNum = 0;
                        $this->readedNum = 0;
                        $this->result = [];
                        $this->executeCb();
                    } else {
                        $this->state = static::STATE_PACKET_DATA;
                    }
                }
            }
        }
        if ($this->state === static::STATE_PACKET_DATA) {
            if ($this->responseCode === static::REPL_KVAL) {
                $keyAdded = false;
                nextElement:
                $l = $this->getInputLength();
                if ($l < 9) {
                    goto cursorCall;
                }
                if (($hdr = $this->lookExact($o = 4)) === false) {
                    goto cursorCall;
                }
                $keyLen = Binary::getDword($hdr, true);
                if (($key = $this->lookExact($keyLen, $o)) === false) {
                    goto cursorCall;
                }
                $o += $keyLen;
                if (($encoding = $this->lookExact(1, $o)) === false) {
                    goto cursorCall;
                }
                $encoding = ord($encoding);
                ++$o;
                if (($hdr = $this->lookExact(4, $o)) === false) {
                    goto cursorCall;
                }
                $o += 4;
                $valLen = Binary::getDword($hdr, true);
                if ($o + $valLen > $l) {
                    goto cursorCall;
                }
                $this->drain($o);
                if ($encoding === static::GB_ENC_NUMBER) {
                    $val = $this->read($valLen);
                    $this->result[$key] = $valLen === 8
                        ? Binary::getQword($val, true)
                        : Binary::getDword($val, true);
                } else {
                    $this->result[$key] = $this->read($valLen);
                }
                $keyAdded = true;
                if (++$this->readedNum >= $this->totalNum) {
                    $this->isFinal = true;
                    $this->executeCb();
                    goto start;
                } else {
                    goto nextElement;
                }
                cursorCall:
                if ($keyAdded) {
                    $this->onResponse->executeAndKeepOne($this);
                }
                return;
            } else {
                if (($this->result = $this->readExact($this->responseLength)) === false) {
                    $this->setWatermark($this->responseLength);
                    return;
                }
                $this->setWatermark(2, $this->pool->maxAllowedPacket);
                if ($this->encoding === static::GB_ENC_NUMBER) {
                    $this->result = $this->responseLength === 8
                        ? Binary::getQword($this->result, true)
                        : Binary::getDword($this->result, true);
                }
                $this->isFinal = true;
                $this->totalNum = 1;
                $this->readedNum = 1;
                $this->executeCb();
            }
        }
        goto start;
    }
211132
protected function onRead($data)
    {
        if (!$this->remove || $this->autocomplete || $this->question->isHidden()) {
            return;
        }

        $this->output->captureUserInput($data);
    }
879358
public function onRead()
    {
        $packet = $this->read(1024);
        $orig = $packet;
        $type = Binary::getByte($packet);
        $code = Binary::getByte($packet);
        $checksum = Binary::getStrWord($packet);
        $id = Binary::getWord($packet);
        $seq = Binary::getWord($packet);
        if ($checksum !== self::checksum(substr_replace($orig, "\x00\x00", 2, 2))) {
            $status = 'badChecksum';
        } elseif ($type === 0x03) {
            $status = isset(static::$unreachableCodes[$code]) ? static::$unreachableCodes[$code] : 'unk' . $code . 'unreachable';
        } else {
            $status = 'unknownType0x' . dechex($type);
        }
        while (!$this->onResponse->isEmpty()) {
            $el = $this->onResponse->shift();
            if ($el instanceof CallbackWrapper) {
                $el = $el->unwrap();
            }
            list($cb, $st) = $el;
            $cb(microtime(true) - $st, $status);
        }
        $this->finish();
    }
804168
public function onMetaParsing()
    {
        // make sure to trigger the onMetaHeaders event
        $this->getMetaHeaders();

        if ($this->triggersApiEvents(self::API_VERSION_0_9, self::API_VERSION_1_0)) {
            $headersFlipped = array_flip($this->metaHeaders);

            $this->triggerEvent(self::API_VERSION_0_9, 'before_read_file_meta', array(&$headersFlipped));
            $this->triggerEvent(self::API_VERSION_1_0, 'onMetaParsing', array(&$this->rawContent, &$headersFlipped));

            $this->updateFlippedMetaHeaders($headersFlipped);
        }
    }
614231
public function read($isRead)
    {
        $this->setProperty("IsRead", $isRead);
        $qry = new UpdateEntityQuery($this);
        $this->getContext()->addQuery($qry);
    }
19089
public function onIndex()
    {
        $this->breadcrumbs->register(self::$name, function(Generator $breadcrumbs) {
            $breadcrumbs->push('General Configuration');
        });

        $this->shareOnView(self::$name);
    }
415980
public function onResultDone()
    {
        $this->rsState = self::RS_STATE_HEADER;
        $this->onResponse->executeOne($this, true);
        $this->checkFree();
        $this->resultRows = [];
        $this->resultFields = [];
    }
738202
public function onReady()
    {
        if ($this->isEnabled()) {
            $this->updateTimer = setTimeout(function ($timer) {
                $this->updateAllServers();
                $timer->timeout(2e6);
            }, 1);
        }
    }
902519
public function onReady()
    {
        $this->redis = \PHPDaemon\Clients\Redis\Pool::getInstance();

        $this->redis->multi(function ($multi) {
            // "OK"
            D('start multi: ' . $multi->result);

            $multi->set('test1', 'value1', function ($redis) use ($multi) {
                // "QUEUED"
                D('in multi 1: ' . $redis->result);

                $this->redis->set('test1', 'value1-new', function ($redis) {
                    // "OK", not "QUEUED"
                    D('out multi 1: ' . $redis->result);
                });

                setTimeout(function ($timer) use ($multi) {
                    // "QUEUED"
                    $multi->set('test2', 'value2', function ($redis) use ($multi) {
                        D('in multi 2: ' . $redis->result);

                        $multi->exec(function ($redis) {
                            D('exec');
                            D($redis->result);
                        });
                    });
                    $timer->free();
                }, 2e5);
            });
        });
    }
905529
function onRead( error, data ) {
		if ( error ) {
			return done( error );
		}
		data = parse( data, opts.reviver );
		if ( data instanceof Error ) {
			return done( data );
		}
		done( null, data );
	}
1339345
public function poll()
    {
        if (! app()->environment('production')) {
            $this->eye->status()->setHealthy('debug');
            return;
        }

        if (config('app.debug')) {
            if ($this->eye->status()->isHealthy('debug')) {
                $this->eye->notifier()->alert(new Enabled);
            }

            $this->eye->status()->setSick('debug');
        } else {
            if ($this->eye->status()->isSick('debug')) {
                $this->eye->notifier()->alert(new Disabled);
            }

            $this->eye->status()->setHealthy('debug');
        }
    }
577052
protected function onRead()
    {
        while (($line = $this->readline()) !== null) {
            $e = explode(' , ', $line);
            if ((sizeof($e) !== 2) || !ctype_digit($e[0]) || !ctype_digit($e[1])) {
                $this->writeln($line . ' : ERROR : INVALID-PORT');
                $this->finish();
                return;
            }
            $local = (int)$e[0];
            $foreign = (int)$e[1];
            if ($user = $this->pool->findPair($local, $foreign)) {
                $this->writeln($line . ' : USERID : ' . $user);
            } else {
                $this->writeln($line . ' : ERROR : NO-USER');
            }
        }
    }
1049772
public function onRead()
    {
        start:
        if ($this->state === static::STATE_HEADER) {
            $l = $this->getInputLength();
            if ($l < 2) {
                return;
            }
            $hdr = $this->look(2);
            $fb = Binary::getbitmap(ord($hdr));
            $fin = (bool)$fb{0};
            $opCode = bindec(substr($fb, 4, 4));

            if (isset($this->opCodes[$opCode])) {
                $this->type = $this->opCodes[$opCode];
            } else {
                $this->log('opCode: ' . $opCode . ': unknown frame type');
                $this->finish();
                return;
            }
            $sb = ord(mb_orig_substr($hdr, 1));
            $sbm = Binary::getbitmap($sb);
            $this->isMasked = (bool)$sbm{0};
            $payloadLength = $sb & 127;

            if ($payloadLength <= 125) {
                $this->drain(2);
                $this->pctLength = $payloadLength;
            } elseif ($payloadLength === 126) {
                if ($l < 4) {
                    return;
                }
                $this->drain(2);
                $this->pctLength = Binary::b2i($this->read(2));
            } elseif ($payloadLength === 127) {
                if ($l < 10) {
                    return;
                }
                $this->drain(2);
                $this->pctLength = Binary::b2i($this->read(8));
            }

            if ($this->pool->maxAllowedPacket < $this->pctLength) {
                Daemon::$process->log('max-allowed-packet (' . $this->pool->config->maxallowedpacket->getHumanValue() . ') exceed, aborting connection');
                $this->finish();
                return;
            }
            $this->setWatermark($this->pctLength + ($this->isMasked ? 4 : 0));
            $this->state = static::STATE_DATA;
        }

        if ($this->state === static::STATE_DATA) {
            if ($this->getInputLength() < $this->pctLength + ($this->isMasked ? 4 : 0)) {
                return;
            }
            $this->state = static::STATE_HEADER;
            $this->setWatermark(2);
            if ($this->isMasked) {
                $this->trigger('frame', static::mask($this->read(4), $this->read($this->pctLength)));
            } else {
                $this->trigger('frame', $this->read($this->pctLength));
            }
        }
        if ($this->state === static::STATE_STANDBY) {
            while (($line = $this->readLine()) !== null) {
                $line = trim($line);
                if ($line === '') {
                    $expectedKey = base64_encode(pack('H*', sha1($this->key . static::GUID)));
                    if (isset($this->headers['HTTP_SEC_WEBSOCKET_ACCEPT']) && $expectedKey === $this->headers['HTTP_SEC_WEBSOCKET_ACCEPT']) {
                        $this->state = static::STATE_HEADER;
                        if ($this->onConnected) {
                            $this->connected = true;
                            $this->onConnected->executeAll($this);
                            $this->onConnected = null;
                        }
                        $this->trigger('connected');
                        goto start;
                    } else {
                        Daemon::$process->log(__METHOD__ . ': Handshake failed. Connection to ' . $this->url . ' failed.');
                        $this->finish();
                    }
                } else {
                    $e = explode(': ', $line);
                    if (isset($e[1])) {
                        $this->headers['HTTP_' . strtoupper(strtr($e[0], ['-' => '_']))] = $e[1];
                    }
                }
            }
            return;
        }
        goto start;
    }
913666
public function onRead()
    {
        if (false === ($pct = $this->readExact($this->lowMark))) {
            return; // not readed yet
        }
        if ($pct === "<policy-file-request/>\x00") {
            if ($this->pool->policyData) {
                $this->write($p = $this->pool->policyData . "\x00");
            } else {
                $this->write("<error/>\x00");
            }
        }
        $this->finish();
    }
770869
public function doRead()
    {
        $data = fread($this->stream, static::READ_CHUNK_SIZE);

        if ($data === '') {
            fclose($this->stream);
            $this->stream = null; //fclose() will only leave stream resource in unknown state

        } elseif ($this->isDegenerated === false) {
            $this->readBuffer .= $data;

            //For explanation read "important note" for processInputBuffer()
            //@formatter:off
            while ($this->processInputBuffer() === false);
            //@formatter:on
        }
    }
758485
public function onUpdate() {
    
    if (file_exists($this->savedTimestampPath)) {
      $readTimestamp = file_get_contents($this->savedTimestampPath);
      if ($readTimestamp != $this->savedTimestamp) {
        foreach ($this->clients as $sendto) {
          $sendto->send($readTimestamp);
        }
        $this->savedTimestamp = $readTimestamp;
      }
    }
    
  }
591157
public function onReady()
    {
        $this->redis = \PHPDaemon\Clients\Redis\Pool::getInstance();

        $params = [];
        foreach (range(0, 100) as $i) {
            $params[] = 'myset' . $i;
            $params[] = 'value' . $i;
        }
        $params[] = function ($redis) {
            $params = [
                function ($redis) {
                    D('Count: ' . count($redis->result[1]) . '; Next: ' . $redis->result[0]);
                }
            ];

            $cbEnd = function ($redis, $scan) {
                D('Full scan end!');
            };

            // test 1
            // $this->redis->scan(...$params);

            // test 2
            $this->redis->autoscan('scan', $params, $cbEnd, 50);
        };
        $this->redis->mset(...$params);
    }