Beispiel #1
0
echo "---------------------------------------------------------\n";
$timeout = gupnp_context_get_subscription_timeout($context);
echo "[RESULT]: ";
var_dump($timeout);
echo "=========================================================\n\n\n";
echo "=========================================================\n";
echo "[CALL]: gupnp_context_set_subscription_timeout({$context}, {$timeout}) \n";
echo "---------------------------------------------------------\n";
$timeout = 1000;
gupnp_context_set_subscription_timeout($context, $timeout);
echo "[RESULT]: set timeout to {$timeout} \n";
echo "=========================================================\n\n\n";
echo "=========================================================\n";
echo "[CALL]: gupnp_context_get_subscription_timeout({$context}) \n";
echo "---------------------------------------------------------\n";
$timeout = gupnp_context_get_subscription_timeout($context);
echo "[RESULT]: ";
var_dump($timeout);
echo "=========================================================\n\n\n";
$local_path_1 = $_SERVER["PWD"] . "/ext/gupnp/examples/BinaryLight1.xml";
$server_path_1 = "/BinaryLight1.xml";
echo "=========================================================\n";
echo "[CALL]: gupnp_context_host_path({$context}, {$local_path_1}, {$server_path_1}) \n";
echo "---------------------------------------------------------\n";
$result = gupnp_context_host_path($context, $local_path_1, $server_path_1);
echo "[RESULT]: ";
var_dump($result);
echo "=========================================================\n\n\n";
$local_path_2 = $_SERVER["PWD"] . "/ext/gupnp/examples/SwitchPower1.xml";
$server_path_2 = "/SwitchPower1.xml";
echo "=========================================================\n";
Beispiel #2
0
printf("Running server:\n");
printf("\thost/ip: %s\n", gupnp_context_get_host_ip($context));
printf("\tport: %d\n", gupnp_context_get_port($context));
/* Host current directory */
gupnp_context_host_path($context, "./web", "");
/* Create root device */
$dev = gupnp_root_device_new($context, "/tvdevicedesc.xml");
/* Get relative location */
$rel_location = gupnp_root_device_get_relative_location($dev);
printf("\trelative location: %s\n", $rel_location);
/* Subscription timeout */
$subs_timeout = gupnp_context_get_subscription_timeout($context);
printf("\tsubscription timeout: %d\n\n", $subs_timeout);
printf("Change timeout:\n");
gupnp_context_set_subscription_timeout($context, 10);
printf("\tsubscription timeout: %d\n\n", gupnp_context_get_subscription_timeout($context));
if (!gupnp_root_device_get_available($dev)) {
    gupnp_root_device_set_available($dev, true);
}
/* Get the service from the root device */
$service_tvcontrol = "urn:schemas-upnp-org:service:tvcontrol:1";
$service = gupnp_device_info_get_service($dev, $service_tvcontrol);
if (!$service) {
    printf("Cannot get %s service\n", $service_tvcontrol);
    exit(-1);
}
/* Set callback for action PowerOn */
gupnp_device_action_callback_set($service, GUPNP_SIGNAL_ACTION_INVOKED, "PowerOn", "power_on_cb", "PowerOn");
/* Set callback for action PowerOff */
gupnp_device_action_callback_set($service, GUPNP_SIGNAL_ACTION_INVOKED, "PowerOff", "power_off_cb", "PowerOff");
/* Set callback for action SetChannel */