Internally used to accept input from the user. Plays pre prompt messages,
prompt, and waits for a complete input or cancel.

@return void
2438
protected function doInput()
    {
        /* @var $result IReadResult */
        $this->resetInput();
        $this->inputAttemptsUsed++;
        $result = $this->playPrePromptMessages();
        if (!$this->acceptPrePromptInputAsInput) {
            $result = $this->playPromptMessages();
            if ($result !== null && !$result->isTimeout()) {
                $this->acceptInput($result->getDigits());
            }
        } elseif ($result !== null && !$result->isTimeout()) {
            $this->acceptInput($result->getDigits());
        } else {
            $result = $this->playPromptMessages();
            if ($result !== null) {
                $this->acceptInput($result->getDigits());
            }
        }
        if ($this->inputLengthIsAtLeast($this->maxInput) // max = 1
            || $this->wasCancelled()
            || ($this->isComplete() && !$this->hasInput()) // user pressed eoi
        ) {
            return;
        }
        $len = strlen($this->input);
        $start = time();
        for ($i = $len; $i < $this->maxInput; $i++) {
            if ($this->totalTimeForInput != -1) {
                $totalElapsedTime = (time() - $start) * 1000;
                if ($totalElapsedTime >= $this->totalTimeForInput) {
                    $this->logDebug("Expired total available time for input");
                    break;
                }
            }
            $this->logDebug($this->name . ": Reading Digit #: " . ($i + 1));
            $result = $this->callClientMethods(array(
                    array('waitDigit' => array($this->timeBetweenDigits))
            ));
            if ($result->isTimeout()) {
                $this->logDebug("Expired available time per digit");
                break;
            }
            $input = $result->getDigits();
            $this->acceptInput($input);
            if ($this->inputIsEnd($input) || $this->wasCancelled()) {
                break;
            }
        }
    }
1193134
public function validate() : void
    {
        if (null === $this->is_valid) {
            if (null === $this->user_value && null !== $this->default_value) {
                // There is a preset value, and its not being changed
                $this->is_valid = true;
            } elseif (true == $this->user_value || 1 == $this->user_value) {
                $this->user_value = 1;
                $this->is_valid = true;
            } elseif (false == $this->user_value || 0 == $this->user_value || '' == $this->user_value) {
                $this->user_value = 0;
                $this->is_valid = true;
            } elseif (false == $this->validator) {
                // This field does not get validated
                $this->is_valid = true;
            } else {
                $this->is_valid = false;
                $this->error = 'The provided value is not valid. Please enter a valid value.';
            }
        }

        // Check if the input is different from the default value
        if ($this->is_valid && null !== $this->user_value) {
            $this->is_changed = ($this->default_value != $this->user_value);
        }
    }
27331
public function limitedAskCommand(): void
    {
        $times = (int)$this->input->getOpt('limit', 3);

        if ($this->input->getBoolOpt('nv')) {
            $a = Interact::limitedAsk('you name is: ', '', null, $times);
        } else {
            $a = Interact::limitedAsk('you name is: ', '', function ($val) {
                if (!\preg_match('/^\w{2,}$/', $val)) {
                    Show::error('Your input must match /^\w{2,}$/');
                    return false;
                }

                return true;
            }, $times);
        }

        $this->write('Your answer is: ' . $a);
    }
1104531
protected function prompt()
	{
		$dialog = $this->getHelperSet()->get('dialog');

		return $dialog->ask($this->output, "<info>></info>", null);
	}
200962
public function run()
	{
		// streams
		$read = [$this->_input];

		$write  = null;
		$except = null;

		// stream ends?
		$end_of_stream = false;

		$waitForMinComputationTime = defined('PROKKIBOT_MIN_COMPUTATION_TIME') && !empty(PROKKIBOT_MIN_COMPUTATION_TIME);

		do
		{

			$changed_streams = stream_select($read, $write, $except, PROKKIBOT_MAX_SERVER_TIMEOUT);

			if( $waitForMinComputationTime )
			{
				$time_start = get_microtime_float();
			}
			
			if( false === $changed_streams )
			{
				die();
			}

			foreach( $read as $_handle )
			{

				$string = trim(fgets($_handle));

				if( empty($string) )
				{
					$end_of_stream = true;
					continue;
				}

				Debugger::Log(sprintf("received: %s\n", $string));

				$end_of_stream = feof($_handle);

				try
				{

					$command = $this->_bot->getParser()->run($string);

//					Debugger::Log(get_class($command) . "\n");

					$command->apply($this->_bot);

//					Debugger::Log("applied\n");

//					Debugger::Log(sprintf("Round: %d, Remaining: %d, Last: %d\n",
//						$this->_environment->getCurrentRoundNo(),
//						$this->_environment->getRemainingRounds(),
//						$this->_environment->isLastRound()
//					));

					if( $command->isComputable() )
					{

						/** @var Computable $command */
						$send = $command->compute($this->_bot);

						if( $waitForMinComputationTime )
						{
							self::_WaitForMinCompuitationTime($time_start);
						}

						fwrite($this->_output, $send . "\n");

						Debugger::Log(sprintf("send: %s\n", $send));
					}

				}
				catch( \Exception $exception )
				{
					Debugger::Log(sprintf("Exception:%s\n\n%s", $exception->getMessage(), $exception->getTraceAsString()));

					$send = "Aborting due an error :-(";

					fwrite($this->_output, $send . "\n");

					Debugger::Log(sprintf("send: %s\n", $send));

					$end_of_stream = true;
				}

			}
		}
		while( !$end_of_stream && !empty($changed_streams) );

		Debugger::Log("MEM: " . size_to_readable_string(memory_get_usage(true)) . "\n");

		Debugger::Log("END!\n");

		fclose($this->_input);
	}
953400
public void acceptPrompt() {
        String action = "Clicking 'OK' on a prompt";
        String expected = "Prompt is present to be clicked";
        if (isNotPrompt(action, expected, "click")) {
            return;
        }
        accept(action, expected, "prompt");
    }
160287
private void fireUserInputChange() {
		if (!internallySettingText && (this.listeners != null)) {
			for (Iterator it = this.listeners.iterator(); it.hasNext();) {
				UserInputListener userInputListener = (UserInputListener) it.next();
				userInputListener.update(this);
			}
		}
	}
1370026
protected function acceptUnknowBrackets()
    {
        $level = 0;

        do
        {
            switch ( $this->buffer[0] )
            {
                case '{':
                    $level++;
                    $this->buffer = substr( $this->buffer, 1 );
                    break;

                case '}':
                    $level--;
                    $this->buffer = substr( $this->buffer, 1 );
                    break;

                default:
                    $this->buffer = preg_replace(
                        '/^[^\{\}]+/', '',
                        $this->buffer
                    );
                    break;
            }
        }
        while ( $level > 0 );
    }
1192574
public function accept()
    {
        $asset = $this->getInnerIterator()->current(true);
        $duplicate = false;

        // check strict equality
        if (in_array($asset, $this->visited, true)) {
            $duplicate = true;
        } else {
            $this->visited[] = $asset;
        }

        // check source
        $sourceRoot = $asset->getSourceRoot();
        $sourcePath = $asset->getSourcePath();
        if ($sourceRoot && $sourcePath) {
            $source = $sourceRoot.'/'.$sourcePath;
            if (in_array($source, $this->sources)) {
                $duplicate = true;
            } else {
                $this->sources[] = $source;
            }
        }

        return !$duplicate;
    }
426238
public function onReady()
    {
        $this->createXMLStream();
        $this->startXMLStream();
        $this->keepaliveTimer = setTimeout(function ($timer) {
            $this->ping();
        }, 1e6 * 30);
    }
401486
public function selectCommand(): void
    {
        $opts = ['john', 'simon', 'rose'];
        // can also: $this->select();
        $a = Interact::select('you name is', $opts);

        $this->write('Your answer is: ' . $opts[$a]);
    }
658017
public function StasisAppEventHandler()
        {
            $this->stasisEvents->on('StasisStart', function ($event) {
                $this->stasisLogger->notice("Event received: StasisStart");
                $this->stasisChannelID = $event->channel->id;
                $this->phpariObject->channels()->channel_answer($this->stasisChannelID);
                $this->phpariObject->channels()->channel_playback($this->stasisChannelID, 'sound:demo-thanks', NULL, NULL, NULL, 'play1');
            });

            $this->stasisEvents->on('StasisEnd', function ($event) {
                /*
                 * The following section will produce an error, as the channel no longer exists in this state - this is intentional
                 */
                $this->stasisLogger->notice("Event received: StasisEnd");
                if (!$this->phpariObject->channels()->channel_delete($this->stasisChannelID))
                    $this->stasisLogger->notice("Error occurred: " . $this->phpariObject->lasterror);
            });


            $this->stasisEvents->on('PlaybackStarted', function ($event) {
                $this->stasisLogger->notice("+++ PlaybackStarted +++ " . json_encode($event->playback) . "\n");
            });

            $this->stasisEvents->on('PlaybackFinished', function ($event) {
                switch ($event->playback->id) {
                    case "play1":
                        $this->phpariObject->channels()->channel_playback($this->stasisChannelID, 'sound:demo-congrats', NULL, NULL, NULL, 'play2');
                        break;
                    case "play2":
                        $this->phpariObject->channels()->channel_playback($this->stasisChannelID, 'sound:demo-echotest', NULL, NULL, NULL, 'end');
                        break;
                    case "end":
                        $this->phpariObject->channels()->channel_continue($this->stasisChannelID);
                        break;
                }
            });

            $this->stasisEvents->on('ChannelDtmfReceived', function ($event) {
                $this->setDtmf($event->digit);
                $this->stasisLogger->notice("+++ DTMF Received +++ [" . $event->digit . "] [" . $this->dtmfSequence . "]\n");
                switch ($event->digit) {
                    case "*":
                        $this->dtmfSequence = "";
                        $this->stasisLogger->notice("+++ Resetting DTMF buffer\n");
                        break;
                    case "#":
                        $this->stasisLogger->notice("+++ Playback ID: " . $this->phpariObject->playbacks()->get_playback());
                        $this->phpariObject->channels()->channel_continue($this->stasisChannelID, "demo", "s", 1);
                        break;
                    default:
                        break;
                }
            });
        }
560271
public static function begin(): void
  {
    $ret = self::$mysqli->autocommit(false);
    if (!$ret) self::mySqlError('mysqli::autocommit');
  }
519451
private function execute()
    {
        $this->connect();
        try {
            $this->getSyntax();
            $this->read->execute();
            $this->result = $this->read->fetchAll();

        } catch (\PDOException $e) {
            $this->result = null;
            $this->erro = "<b>Erro ao Ler: ({$this->tabela})</b> {$e->getMessage()}";
        }

        parent::setDefault();
    }
1124813
private function handleInputPrivate()
    {
        $this->parseVerbosity();
        $this->parseFieldsProvided();
        $this->parseToken();
        $this->parseSourceId();
        $this->parseSource();
        $this->parseCampaignId();
        $this->validateToken();
        $this->parseSourceCampaignSettings();
        $this->parseCampaign();

        return $this;
    }
1049679
def handle_input(self, input_str, place=True, check=False):
        ''''''
        user = self.get_player()
        pos = self.validate_input(input_str)
        if pos[0] == 'u':
            self.undo(pos[1])
            return pos
        if place:
            result = self.set_pos(pos, check)
            return result
        else:
            return pos
1021932
protected function onInit()
    {
        // $this->connection = Util::get($this->params,"connection",null);
        $connectionString = Util::get($this->params, "connectionString", "");
        $username = Util::get($this->params, "username", "");
        $password = Util::get($this->params, "password", "");
        $charset = Util::get($this->params, "charset");
        
        $key = md5($connectionString.$username.$password);
        if (PdoDataSource::$connections==null) {
            PdoDataSource::$connections = array();
        }
        if (isset(PdoDataSource::$connections[$key])) {
            $this->connection = PdoDataSource::$connections[$key];
        } else {
            $this->connection = new PDO($connectionString, $username, $password);
            PdoDataSource::$connections[$key] = $this->connection;
        }
        if ($charset) {
            $this->connection->exec("set names '$charset'");
        }
    }