PHPMQTT v1.2.1 版本发布,MQTT 协议解析 & 协程客户端

栏目: 软件资讯 · 发布时间: 5年前

内容简介:v1.2 版本主要修改了 Client 的构造函数参数和 Protocol 的命名空间,以及优化重连逻辑。 Protocol 新增一层Protocol,使用V3和V5来区分 MQTT 协议等级。 同时将Simps\MQTT\Types也移动到了Protocol下,修改为Sim...

v1.2 版本主要修改了 Client 的构造函数参数和 Protocol 的命名空间,以及优化重连逻辑。

Protocol

新增一层Protocol,使用V3V5来区分 MQTT 协议等级。

同时将Simps\MQTT\Types也移动到了Protocol下,修改为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 之前是直接传递数组参数的,现在改为对象的方式。

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);

更新日志

向下不兼容

  • 更新命名空间 (2204df6) (28f8abe)

移除

  • 不支持 PHP 7.0 (3dc5bcd)

增强

  • 为所有的常量添加可见性标识符 (0176469)
  • 新增 ClientConfig (d90b9dc)
  • 优化 Client (9229224)
  • 更新测试和示例代码 (959a21d) (08531ac)
  • 增加重连次数限制和优化重连延迟时间 (#32)

关于 PHPMQTT

  • MQTT 协议解析 & 协程客户端
  • 适用于 PHP 的 MQTT 协议解析和协程客户端
  • 支持 MQTT 协议 3.1、3.1.1 和 5.0 版本,支持 QoS 0、QoS 1、QoS 2
  • 首个支持 MQTT v5.0 协议的 PHP library

文档:https://mqtt.simps.io
GitHub:https://github.com/simps/mqtt
Gitee:https://gitee.com/phpiot/mqtt

支持记得点个 Star~


以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,也希望大家多多支持 码农网

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

Data Structures and Algorithm Analysis in Java

Data Structures and Algorithm Analysis in Java

Mark A. Weiss / Pearson / 2011-11-18 / GBP 129.99

Data Structures and Algorithm Analysis in Java is an “advanced algorithms” book that fits between traditional CS2 and Algorithms Analysis courses. In the old ACM Curriculum Guidelines, this course wa......一起来看看 《Data Structures and Algorithm Analysis in Java》 这本书的介绍吧!

RGB转16进制工具
RGB转16进制工具

RGB HEX 互转工具

SHA 加密
SHA 加密

SHA 加密工具

XML 在线格式化
XML 在线格式化

在线 XML 格式化压缩工具