©
本文档使用 PHP中文网手册 发布
(PECL gupnp >= 0.1.0)
gupnp_control_point_callback_set — Set control point callback
$cpoint
, int $signal
, mixed $callback
[, mixed $arg
] )Set control point callback function for signal.
cpoint
A control point identifier, returned by gupnp_control_point_new() .
signal
The value of signal. Signal can be one of the following values:
GUPNP_SIGNAL_DEVICE_PROXY_AVAILABLE
GUPNP_SIGNAL_DEVICE_PROXY_UNAVAILABLE
GUPNP_SIGNAL_SERVICE_PROXY_AVAILABLE
GUPNP_SIGNAL_SERVICE_PROXY_UNAVAILABLE
callback
The callback function for the certain signal. Typically, callback function
takes on two parameters. The proxy
parameter's
identifier being the first, and the arg
second.
arg
User data for callback
.
成功时返回 TRUE
, 或者在失败时返回 FALSE
。
Example #1 Create new UPnP context and start browsing
<?php
function device_proxy_available_cb ( $proxy , $arg )
{
$info = gupnp_device_info_get ( $proxy );
$type = $info [ 'device_type' ];
$location = $info [ 'location' ];
printf ( "Device available:\n" );
printf ( "type: %s\n" , $type );
printf ( "location: %s\n" , $location );
}
$context = gupnp_context_new ();
if (! $context ) {
die( "Error creating the GUPnP context\n" );
}
$cp = gupnp_control_point_new ( $context , "ssdp:all" );
gupnp_control_point_callback_set ( $cp ,
GUPNP_SIGNAL_DEVICE_PROXY_AVAILABLE , 'device_proxy_available_cb' );
gupnp_control_point_browse_start ( $cp );
?>
Issues E_WARNING with not valid callback function.