-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclient.php
70 lines (44 loc) · 1.52 KB
/
client.php
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
require_once __DIR__ . '/../vendor/autoload.php';
$data = [
'beam' => ['kirk', 'spock'],
'to' => 'earth'
];
$outputStream = new \Hawkbit\DataStream\OutputStream($data);
echo 'Capture beaming sequence ' . $outputStream . PHP_EOL . PHP_EOL;
echo 'Beaming sequence ';
sleep(1);
echo 'initiated!' . PHP_EOL;
sleep(1);
echo 'Beaming ';
// perform inter-process communication
// send data via cli, rest, pubsub or something like that
// we send data to endpoint.php and also want to receive data from endpoint php
$payload = exec(sprintf('php endpoint.php %s', $outputStream));
echo 'finished' . PHP_EOL . PHP_EOL;
echo 'Receive beaming feedback sequence ';
sleep(3);
echo $payload . PHP_EOL . PHP_EOL;
// create input stream from input and read data
$inputStream = new \Hawkbit\DataStream\InputStream($payload);
$result = $inputStream->getData();
echo 'Destination: ';
sleep(1);
// check that kirk and spock has been beamed
if($result['destination'] !== $data['to']){
echo 'Not OK!' . PHP_EOL;
echo sprintf('Oh no! Expected destination to be %s and not %s', $data['to'],
$result['destination']) . PHP_EOL;
}
echo 'OK!' . PHP_EOL;
$beam = implode(' and ', $data['beam']);
$beamed = implode(' and ', $result['beamed']);
echo 'Persons: ';
sleep(2);
if($beam !== $beamed){
echo 'Not OK!' . PHP_EOL;
echo sprintf('Oh no! Expected beamed persons to be %s and not %s', $beam, $beamed) . PHP_EOL;
}
echo 'OK!' . PHP_EOL . PHP_EOL;
usleep(800);
echo sprintf('%s beamed to %s', $beamed, $result['destination']);