示例#1
0
文件: Http.php 项目: jibinam/budabot2
 /**
  * Requests contents of given $uri using POST method and returns AsyncHttp
  * object which has additional methods for controlling how the query is done.
  *
  * See get() for code example.
  *
  * @param string $uri the requested URI
  * @return AsyncHttp
  */
 public function post($uri)
 {
     $http = new AsyncHttp('post', $uri);
     Registry::injectDependencies($http);
     $this->timer->callLater(0, array($http, 'execute'));
     return $http;
 }
示例#2
0
 private function startRpcServer()
 {
     $vars = $this->getConfigVars();
     $this->rpcService = new RunnerRpcService();
     Registry::injectDependencies($this->rpcService);
     $this->rpcService->start($vars['testbotrunner_rpc_port']);
 }
示例#3
0
 public static function getInstance($name, $reload = false)
 {
     $name = strtolower($name);
     LegacyLogger::log("DEBUG", "Registry", "Requesting instance for '{$name}'");
     $instance = Registry::$repo[$name];
     if ($instance == null) {
         LegacyLogger::log("WARN", "Registry", "Could not find instance for '{$name}'");
     }
     if ($instance !== null && (USE_RUNKIT_CLASS_LOADING === true || $reload === true)) {
         Registry::importChanges($instance);
         Registry::injectDependencies($instance);
     }
     return $instance;
 }
示例#4
0
 /**
  * Waits until response is fully received from remote server and returns
  * the response. Note that this blocks execution, but do not freeze the bot
  * as the execution will return to event loop while waiting.
  *
  * @return mixed
  */
 public function waitAndReturnResponse()
 {
     // run in event loop, waiting for loop->quit()
     $this->loop = new EventLoop();
     Registry::injectDependencies($this->loop);
     $this->loop->exec();
     return $this->buildResponse();
 }
示例#5
0
 public function run()
 {
     $loop = new EventLoop();
     Registry::injectDependencies($loop);
     $loop->exec();
 }
示例#6
0
 public function getSettingHandler($row)
 {
     $handler = null;
     switch ($row->type) {
         case 'color':
             $handler = new ColorSettingHandler($row);
             break;
         case 'text':
             $handler = new TextSettingHandler($row);
             break;
         case 'number':
             $handler = new NumberSettingHandler($row);
             break;
         case 'options':
             $handler = new OptionsSettingHandler($row);
             break;
         case 'time':
             $handler = new TimeSettingHandler($row);
             break;
         default:
             $this->loggger->log('ERROR', "Could not find setting handler for setting type: '{$row->type}'");
     }
     Registry::injectDependencies($handler);
     return $handler;
 }
示例#7
0
 /**
  * @HandlesCommand("reloadinstance")
  * @Matches("/^reloadinstance all$/i")
  */
 public function reloadinstanceCommand($message, $channel, $sender, $sendto, $args)
 {
     $instances = Registry::getAllInstances();
     $count = count($instances);
     $blob = '';
     foreach ($instances as $name => $instance) {
         $blob .= $name . ' (' . get_class($instance) . ")\n";
         Registry::importChanges($instance);
         Registry::injectDependencies($instance);
     }
     $msg = $this->text->make_blob("All instances have been reloaded ({$count})", $blob);
     $sendto->reply($msg);
 }