Пример #1
0
function set_target_cb($service, $action, $arg)
{
    /* Get the new target value */
    $target = gupnp_service_action_get($action, 'NewTargetValue', GUPNP_TYPE_BOOLEAN);
    /* If the new target doesn't match the current status, change the status and
       emit a notification that the status has changed. */
    if ($target != $GLOBALS['status']) {
        $GLOBALS['status'] = $target;
        gupnp_service_notify($service, 'Status', GUPNP_TYPE_BOOLEAN, $GLOBALS['status']);
        printf("The light is now %s.\n", $GLOBALS['status'] ? "on" : "off");
    }
    /* Return success to the client */
    gupnp_service_action_return($action);
}
Пример #2
0
function set_channel_cb($service, $action, $arg)
{
    printf("Call for action:\n");
    printf("\taction: %s\n", $arg);
    $target = gupnp_service_action_get($action, 'Channel', GUPNP_TYPE_INT);
    if ($target != $GLOBALS['channel']) {
        $GLOBALS['channel'] = $target;
        printf("Call gupnp_service_notify\n");
        $result = gupnp_service_notify($service, 'Channel', GUPNP_TYPE_INT, $GLOBALS['channel']);
        printf("\tresult: channel has been changed to %d.\n", $GLOBALS['channel']);
        gupnp_service_action_return($action);
    } else {
        gupnp_service_action_return_error($action, 100, "this channel number is already set");
    }
    printf("\n");
}
Пример #3
0
function action_settarget_cb($service, $action, $arg)
{
    echo "=========================================================\n";
    echo "[CALL] action_settarget_cb()\n";
    echo "---------------------------------------------------------\n";
    echo "[SERVICE]: ";
    var_dump($service);
    echo "[ACTION]: ";
    var_dump($action);
    echo "[ARG]: ";
    var_dump($arg);
    echo "---------------------------------------------------------\n";
    echo "[CALL]: gupnp_service_action_get({$action}, 'NewTargetValue', GUPNP_TYPE_BOOLEAN) \n";
    echo "---------------------------------------------------------\n";
    $res = gupnp_service_action_get($action, 'NewTargetValue', GUPNP_TYPE_BOOLEAN);
    echo "[RESULT]: ";
    var_dump($res);
    echo "---------------------------------------------------------\n\n";
    if ($GLOBALS['status'] != $res) {
        $GLOBALS['status'] = $res;
    }
    echo "---------------------------------------------------------\n";
    echo "[CALL]: gupnp_service_notify({$service}, 'Status', GUPNP_TYPE_BOOLEAN, " . $GLOBALS['status'] . ") \n";
    echo "---------------------------------------------------------\n";
    $res = gupnp_service_notify($service, 'Status', GUPNP_TYPE_BOOLEAN, $GLOBALS['status']);
    echo "[RESULT]: ";
    var_dump($res);
    echo "---------------------------------------------------------\n\n";
    echo "---------------------------------------------------------\n";
    echo "[CALL]: gupnp_service_action_return({$action}) \n";
    echo "---------------------------------------------------------\n";
    $res = gupnp_service_action_return($action);
    echo "[RESULT]: ";
    var_dump($res);
    echo "---------------------------------------------------------\n\n";
    echo "=========================================================\n\n\n";
}