public function run($port)
    {
        $port = (integer)$port;
        if ($port < 1) {
            throw new \RuntimeException("Invalid port specified for Teleport HTTP Server", E_USER_ERROR);
        }

        /** @var \React\EventLoop\LibEventLoop $loop */
        $loop = \React\EventLoop\Factory::create();
        $socket = new \React\Socket\Server($loop);
        $http = new \React\Http\Server($socket);
        
        $server =& $this;

        $http->on('request', function ($request, $response) use ($server) {
            /** @var \React\Http\Request $request */
            /** @var \React\Http\Response $response */

            $arguments = $request->getQuery();
            $arguments['action'] = trim($request->getPath(), '/');

            $headers = array(
                'Content-Type' => 'text/javascript'
            );
            if (isset($arguments['action']) && !empty($arguments['action']) && strpos($arguments['action'], '.') === false) {
                try {
                    /** @var \Teleport\Request\Request $request */
                    $request = $server->getRequest('Teleport\\Request\\APIRequest');
                    $request->handle($arguments);
                    $results = $request->getResults();

                    $response->writeHead(200, $headers);
                    $response->end(json_encode(array('success' => true, 'message' => $results)));
                } catch (InvalidRequestException $e) {
                    $response->writeHead(400, $headers);
                    $response->end(json_encode(array('success' => false, 'message' => $e->getMessage())));
                } catch (\Exception $e) {
                    $response->writeHead(500, $headers);
                    $response->end(json_encode(array('success' => false, 'message' => $e->getMessage())));
                }
            } else {
                $response->writeHead(400, $headers);
                $response->end(json_encode(array('success' => false, 'message' => 'no valid action was specified')));
            }
        });

        if ($this->getConfig()->get('verbose', null, false) || $this->getConfig()->get('debug', null, false)) {
            echo "teleport server initializing" . PHP_EOL;
        }
        $socket->listen($port);
        if ($this->getConfig()->get('verbose', null, false) || $this->getConfig()->get('debug', null, false)) {
            echo "teleport server listening on port {$port}" . PHP_EOL;
        }
        $loop->run();
    }