diff --git a/src/Client.php b/src/Client.php index 640bad5..443ade6 100644 --- a/src/Client.php +++ b/src/Client.php @@ -187,7 +187,7 @@ private function reConnect(int $delay) public function send(array $data, bool $response = true) { - if ($this->config['protocol_level'] === 5) { + if ($this->config['protocol_level'] === ProtocolInterface::MQTT_PROTOCOL_LEVEL_5_0) { $package = ProtocolV5::pack($data); } else { $package = Protocol::pack($data); @@ -218,7 +218,7 @@ public function recv() throw new RuntimeException($errMsg, $this->client->errCode); } } elseif (is_string($response) && strlen($response) > 0) { - if ($this->config['protocol_level'] === 5) { + if ($this->config['protocol_level'] === ProtocolInterface::MQTT_PROTOCOL_LEVEL_5_0) { return ProtocolV5::unpack($response); } diff --git a/tests/V3/PacketTest.php b/tests/V3/PacketTest.php index 05840f6..c38830c 100644 --- a/tests/V3/PacketTest.php +++ b/tests/V3/PacketTest.php @@ -123,10 +123,10 @@ public function testClose(Client $client) public function testPublishNonTopic() { - $client = new Client(getTestMQTT5ConnectConfig(false), SWOOLE_MQTT_CONFIG); + $client = new Client(getTestConnectConfig(false), SWOOLE_MQTT_CONFIG); $client->connect(); $this->expectException(ProtocolException::class); - $this->expectExceptionMessage('Protocol Error, Topic cannot be empty or need to set topic_alias'); + $this->expectExceptionMessage('Protocol Error, Topic cannot be empty'); $client->publish('', 'hello,simps'); return $client;