Ejemplo n.º 1
0
    $request->setSocket($socket);
    $request->getBuffer();
    $request->parseBuffer();
    $response = new Response();
    $response->setRequest($request);
    if (class_exists($request->getUri())) {
        $handler_name = $request->getUri();
        $handler = new $handler_name();
        $response->setHandler($handler);
    } else {
        // TODO: 404
        echo "cannot find class " . $request->getUri();
    }
    $response->sendData();
    unset($response);
} while ($running);
socket_shutdown($server_socket);
socket_close($server_socket);
try {
    $droid->exit();
    die("Script exited normally\r\n");
} catch (Exception $e) {
    $droid->vibrate(30);
    echo "Exception:" . $e->getMessage();
    $droid->notify('Exception', $e->getMessage());
    $droid->exit();
    die("script exited with an exception");
}
?>
 
Ejemplo n.º 2
0
     $droid->dialogDismiss();
     break;
 case "choose_and_ask":
     $droid->dialogCreateAlert("Choose your sign:");
     $zodiac = array("aries", "taurus", "gemini", "cancer", "leo", "virgo", "libra", "scorpio", "sagittarius", "capricorn", "aquarius", "pisces");
     $droid->dialogSetItems($zodiac);
     $droid->dialogShow();
     $result = $droid->dialogGetResponse();
     $url = "http://widgets.fabulously40.com/horoscope.json?sign=" . $zodiac[$result['result']->item];
     // Downloading the horoscope might take a while...
     $droid->dialogCreateSpinnerProgress("Retrieving information...", "Please wait");
     $droid->dialogShow();
     // Downloading and de-json-ing
     $result = json_decode(file_get_contents($url));
     // we are ready!
     $droid->vibrate();
     // Close spinner
     $droid->dialogDismiss();
     $theFuture = html_entity_decode($result->horoscope->horoscope, ENT_QUOTES, "UTF-8");
     // Something is wrong with '...
     $theFuture = str_replace("'", "'", $theFuture);
     $theFuture .= "\n\n[widgets.fabulously40.com]";
     $droid->dialogCreateAlert("Your Future is here " . $result->horoscope->sign . "!", $theFuture);
     $droid->dialogSetPositiveButtonText("Exit");
     $droid->dialogShow();
     // Wait for user input to continue script
     $droid->dialogGetResponse();
     $action = "bye";
     break;
 case "bye":
     $droid->makeToast("Trust the PFAewok!");