©
本文檔使用 php中文網手册 發布
(PECL gupnp >= 0.1.0)
gupnp_context_timeout_add — Sets a function to be called at regular intervals
$context
, int $timeout
, mixed $callback
[, mixed $arg
] )Sets a function to be called at regular intervals.
context
A context identifier, returned by gupnp_context_new() .
timeout
A timeout in miliseconds.
callback
The callback function calling every timeout
period of time.
Typically, callback function takes on arg
parameter.
arg
User data for callback
.
成功时返回 TRUE
, 或者在失败时返回 FALSE
。
Example #1 Create new UPnP context and set callback
<?php
$user_data = "user data" ;
function timeout_cb ( $arg )
{
printf ( "Call timeout_cb, user data: '%s'" , $arg );
return true ;
}
$context = gupnp_context_new ();
if (! $context ) {
die( "Error creating the GUPnP context\n" );
}
$dev = gupnp_root_device_new ( $context , "/devicedesc.xml" );
gupnp_context_timeout_add ( $context , 5000 , "timeout_cb" , $user_data );
gupnp_root_device_start ( $dev );
?>
Issues E_WARNING with not valid callback function.