-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathget_request.php
More file actions
67 lines (45 loc) · 1.18 KB
/
get_request.php
File metadata and controls
67 lines (45 loc) · 1.18 KB
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
<?php /*
header('Content-Type: text/event-stream');
header('Cache-Control: no-cache');
include './sign-out-class.php';
$sign = new sign_out("localhost", "root", "", "lsmsa");
$last = 0;
$requests = $sign->get_requests();
echo "data: [\n";
foreach($requests as $val) {
echo "data: ".json_encode($val).",\n";
}
echo "data: ]";
//echo "event: thing\n";
echo "data: hello";
flush();
*/
?>
<?php
date_default_timezone_set("America/New_York");
header("Content-Type: text/event-stream\n\n");
include './sign-out-class.php';
$counter = rand(1, 10);
while (1) {
// 1 is always true, so repeat the while loop forever
echo "event: ping\n";
$curDate = date(DATE_ISO8601);
echo 'data: {"time": "' . $curDate . '"}';
echo "\n\n";
$sign = new sign_out("localhost", "root", "", "lsmsa");
$last = 0;
$requests = $sign->get_requests();
echo "data: [\n";
foreach($requests as $val) {
echo "data: ".json_encode($val).",\n";
}
echo "data: ]";
// Send a simple message at random intervals.
// flush the output buffer and send echoed messages to the browser
while (ob_get_level() > 0) {
ob_end_flush();
}
flush();
// sleep for 1 second before running the loop again
sleep(4);
}