The v1.2 version mainly modified the Client's constructor parameters and Protocol's namespace, and optimized the reconnection logic.
Protocol
Add a new layer Protocol
, and use V3
and V5
to distinguish MQTT protocol levels.
At the same time, it will Simps\MQTT\Types
also be moved to the Protocol
next and modified to Simps\MQTT\Protocol\Types
.
1.1
Simps\MQTT\Protocol::pack(array $array)
Simps\MQTT\ProtocolV5::pack(array $array)
Simps\MQTT\ProtocolInterface::MQTT_PROTOCOL_LEVEL_3_1;
Simps\MQTT\Types::CONNECT;
1.2
Simps\MQTT\Protocol\V3::pack(array $array)
Simps\MQTT\Protocol\V5::pack(array $array)
Simps\MQTT\Protocol\ProtocolInterface::MQTT_PROTOCOL_LEVEL_3_1;
Simps\MQTT\Protocol\Types::CONNECT;
Client
Client used to pass array parameters directly, but now it is changed to object mode.
1.1
use Simps\MQTT\Client;
$config = [
'host' => '127.0.0.1',
'port' => 1883,
'user_name' => '',
'password' => '',
'client_id' => Client::genClientID(),
'keep_alive' => 10,
];
$swooleConfig = [
'open_mqtt_protocol' => true,
'package_max_length' => 2 * 1024 * 1024,
'connect_timeout' => 1.0,
'write_timeout' => 3.0,
'read_timeout' => 0.5,
];
$client = new Client($config, $swooleConfig);
1.2
use Simps\MQTT\Client;
use Simps\MQTT\Config\ClientConfig;
$config = new ClientConfig();
$config->setUserName('')
->setPassword('')
->setClientId(Client::genClientID())
->setKeepAlive(10);
$swooleConfig = [
'open_mqtt_protocol' => true,
'package_max_length' => 2 * 1024 * 1024,
'connect_timeout' => 1.0,
'write_timeout' => 3.0,
'read_timeout' => 0.5,
];
$config->setSwooleConfig($swooleConfig);
$client = new Client('127.0.0.1', 1883, $config);
// 也可以这样设置
$config = new ClientConfig([
'userName' => '',
'password' => '',
'clientId' => '',
'keepAlive' => 10,
'protocolName' => 'MQTT',
'protocolLevel' => 4,
'properties' => [],
'delay' => 3000, // 3s
'swooleConfig' => []
]);
$client = new Client('127.0.0.1', 1883, $config);
Update log
Downwardly incompatible
- Update namespace (2204df6) (28f8abe)
Remove
- Does not support PHP 7.0 (3dc5bcd)
Enhance
- Add visibility identifier for all constants (0176469)
- Added ClientConfig (d90b9dc)
- Optimize Client (9229224)
- Update test and sample code (959a21d) (08531ac)
- Increase the limit of the number of reconnections and optimize the reconnection delay time (#32)
About PHPMQTT
- MQTT protocol analysis & coroutine client
- MQTT protocol analysis and coroutine client for PHP
- Support MQTT protocol 3.1, 3.1.1 and 5.0 version, support QoS 0, QoS 1, QoS 2
- The first PHP library that supports MQTT v5.0 protocol
文档:https://mqtt.simps.io
GitHub:https://github.com/simps/mqtt
Gitee:https://gitee.com/phpiot/mqtt
Support remember to order a Star~