-
-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add mqtt constants * Add COMPOSER_ROOT_VERSION
- Loading branch information
1 parent
2a8d2c7
commit d7e27ae
Showing
5 changed files
with
118 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,3 +5,4 @@ | |
/.php-cs-fixer.php export-ignore | ||
/phpunit.xml.dist export-ignore | ||
/tests export-ignore | ||
/bin export-ignore |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
#!/usr/bin/env php | ||
<?php | ||
|
||
include 'vendor/autoload.php'; | ||
|
||
use Simps\MQTT\Protocol\Types; | ||
use Simps\MQTT\Protocol\ProtocolInterface; | ||
|
||
function getConstants(string $objectOrClass) | ||
{ | ||
$objClass = new \ReflectionClass($objectOrClass); | ||
return $objClass->getConstants(); | ||
} | ||
|
||
function genData(array $constants, string $prefix = '') | ||
{ | ||
$data = ''; | ||
foreach ($constants as $name => $value) { | ||
$value = is_int($value) ? $value : "'{$value}'"; | ||
$data .= "define('{$prefix}{$name}', $value);\n"; | ||
} | ||
return $data; | ||
} | ||
|
||
$constants = "<?php | ||
/** | ||
* This file is part of Simps | ||
* | ||
* @link https://github.com/simps/mqtt | ||
* @contact Lu Fei <lufei@simps.io> | ||
* | ||
* For the full copyright and license information, | ||
* please view the LICENSE file that was distributed with this source code | ||
*/ | ||
declare(strict_types=1); | ||
"; | ||
|
||
$protocolConstants = getConstants(ProtocolInterface::class); | ||
$constants .= genData($protocolConstants); | ||
$typeConstants = getConstants(Types::class); | ||
$constants .= genData($typeConstants, 'MQTT_TYPE_'); | ||
|
||
$verbose = [ | ||
'NONE' => 0, | ||
'HEXDUMP' => 1, | ||
'HEXDUMP_ASCII' => 2, | ||
'ASCII' => 3, | ||
'TEXT' => 4, | ||
'HEX_STREAM' => 5, | ||
]; | ||
$constants .= genData($verbose, 'MQTT_VERBOSE_'); | ||
|
||
file_put_contents('src/constants.php', $constants); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<?php | ||
/** | ||
* This file is part of Simps | ||
* | ||
* @link https://github.com/simps/mqtt | ||
* @contact Lu Fei <lufei@simps.io> | ||
* | ||
* For the full copyright and license information, | ||
* please view the LICENSE file that was distributed with this source code | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
define('MQTT_PROTOCOL_LEVEL_3_1', 3); | ||
define('MQTT_PROTOCOL_LEVEL_3_1_1', 4); | ||
define('MQTT_PROTOCOL_LEVEL_5_0', 5); | ||
define('MQISDP_PROTOCOL_NAME', 'MQIsdp'); | ||
define('MQTT_PROTOCOL_NAME', 'MQTT'); | ||
define('MQTT_QOS_0', 0); | ||
define('MQTT_QOS_1', 1); | ||
define('MQTT_QOS_2', 2); | ||
define('MQTT_RETAIN_0', 0); | ||
define('MQTT_RETAIN_1', 1); | ||
define('MQTT_RETAIN_2', 2); | ||
define('MQTT_DUP_0', 0); | ||
define('MQTT_DUP_1', 1); | ||
define('MQTT_SESSION_PRESENT_0', 0); | ||
define('MQTT_SESSION_PRESENT_1', 1); | ||
define('MQTT_TYPE_CONNECT', 1); | ||
define('MQTT_TYPE_CONNACK', 2); | ||
define('MQTT_TYPE_PUBLISH', 3); | ||
define('MQTT_TYPE_PUBACK', 4); | ||
define('MQTT_TYPE_PUBREC', 5); | ||
define('MQTT_TYPE_PUBREL', 6); | ||
define('MQTT_TYPE_PUBCOMP', 7); | ||
define('MQTT_TYPE_SUBSCRIBE', 8); | ||
define('MQTT_TYPE_SUBACK', 9); | ||
define('MQTT_TYPE_UNSUBSCRIBE', 10); | ||
define('MQTT_TYPE_UNSUBACK', 11); | ||
define('MQTT_TYPE_PINGREQ', 12); | ||
define('MQTT_TYPE_PINGRESP', 13); | ||
define('MQTT_TYPE_DISCONNECT', 14); | ||
define('MQTT_TYPE_AUTH', 15); | ||
define('MQTT_VERBOSE_NONE', 0); | ||
define('MQTT_VERBOSE_HEXDUMP', 1); | ||
define('MQTT_VERBOSE_HEXDUMP_ASCII', 2); | ||
define('MQTT_VERBOSE_ASCII', 3); | ||
define('MQTT_VERBOSE_TEXT', 4); | ||
define('MQTT_VERBOSE_HEX_STREAM', 5); |