gupnp_context_timeout_add

(PECL gupnp >= 0.1.0)
Sets a function to be called at regular intervals
bool gupnp_context_timeout_add ( resource $context, int $timeout, mixed $callback [, mixed $arg ] )

Sets a function to be called at regular intervals.

Parameters:
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.

Returns:

Returns TRUE on success or FALSE on failure.

Exception:

Issues E_WARNING with not valid callback function.

Examples:
Create new UPnP context and set callback
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
<?php
 
$user_data "user data";
 
function timeout_cb($arg)
{
    printf("Call timeout_cb, user data: '%s'"$arg);
    return true;
}
 
/* Create the UPnP context */
$context = gupnp_context_new();
 
if (!$context) {
 die("Error creating the GUPnP context\n");
}
 
/* Create root device */
$dev = gupnp_root_device_new($context"/devicedesc.xml");
 
/* Set callback for timeout */
gupnp_context_timeout_add($context, 5000, "timeout_cb"$user_data);
 
/* Run the main loop */
gupnp_root_device_start($dev);
 
?>
See also:

gupnp_context_new() -

doc_php
2025-01-10 15:47:30
Comments
Leave a Comment

Please login to continue.