PHPDaemon\Servers\IRCBouncer\Connection::onRead PHP Method

onRead() public method

Called when new data received
public onRead ( ) : void
return void
    public function onRead()
    {
        Timer::setTimeout($this->keepaliveTimer);
        while (($line = $this->readline()) !== null) {
            if ($line === '') {
                continue;
            }
            if (mb_orig_strlen($line) > 512) {
                Daemon::$process->log('IRCBouncerConnection error: buffer overflow.');
                $this->finish();
                return;
            }
            $line = mb_orig_substr($line, 0, -mb_orig_strlen($this->EOL));
            $p = mb_orig_strpos($line, ':', 1);
            $max = $p ? substr_count($line, " ", 0, $p) + 1 : 18;
            $e = explode(" ", $line, $max);
            $i = 0;
            $cmd = $e[$i++];
            $args = [];
            for ($s = min(sizeof($e), 14); $i < $s; ++$i) {
                if ($e[$i][0] === ':') {
                    $args[] = mb_orig_substr($e[$i], 1);
                    break;
                }
                $args[] = $e[$i];
            }
            if (ctype_digit($cmd)) {
                $code = (int) $cmd;
                $cmd = isset(IRC::$codes[$code]) ? IRC::$codes[$code] : 'UNKNOWN-' . $code;
            }
            $this->onCommand($cmd, $args);
        }
        if (mb_orig_strlen($this->buf) > 512) {
            Daemon::$process->log('IRCClientConnection error: buffer overflow.');
            $this->finish();
        }
    }