-
-
Notifications
You must be signed in to change notification settings - Fork 59
/
Copy pathbootstrap.php
74 lines (65 loc) · 1.8 KB
/
bootstrap.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
68
69
70
71
72
73
74
<?php
/**
* This file is part of Simps.
*
* @link https://github.com/simps/mqtt
* @contact Lu Fei <[email protected]>
*
* For the full copyright and license information,
* please view the LICENSE file that was distributed with this source code.
*/
foreach (
[
__DIR__ . '/../vendor/autoload.php',
__DIR__ . '/vendor/autoload.php',
__DIR__ . '/../../../autoload.php',
] as $file
) {
if (file_exists($file)) {
require_once $file;
break;
}
}
use Simps\MQTT\Client;
use Simps\MQTT\Config\ClientConfig;
const SSL_CERTS_DIR = __DIR__ . '/ssl_certs';
const TESTS_DIR = __DIR__ . '/../tests';
const SWOOLE_MQTT_CONFIG = [
'open_mqtt_protocol' => true,
'package_max_length' => 2 * 1024 * 1024,
'connect_timeout' => 5.0,
'write_timeout' => 5.0,
'read_timeout' => 5.0,
];
const SIMPS_MQTT_LOCAL_HOST = '127.0.0.1';
const SIMPS_MQTT_REMOTE_HOST = 'broker.emqx.io';
const SIMPS_MQTT_PORT = 1883;
const SIMPS_MQTT_OVER_WEBSOCKET_PORT = 8083;
function getTestConnectConfig()
{
$config = new ClientConfig();
return $config->setUserName('')
->setPassword('')
->setClientId(Client::genClientID())
->setKeepAlive(10)
->setDelay(3000) // 3s
->setMaxAttempts(5)
->setSwooleConfig(SWOOLE_MQTT_CONFIG);
}
function getTestMQTT5ConnectConfig()
{
$config = new ClientConfig();
return $config->setUserName('')
->setPassword('')
->setClientId(Client::genClientID())
->setKeepAlive(10)
->setDelay(3000) // 3s
->setMaxAttempts(5)
->setProperties([
'session_expiry_interval' => 60,
'receive_maximum' => 65535,
'topic_alias_maximum' => 65535,
])
->setProtocolLevel(5)
->setSwooleConfig(SWOOLE_MQTT_CONFIG);
}