-
-
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.
- Loading branch information
1 parent
b9d4365
commit 36f6a9d
Showing
1 changed file
with
51 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,51 @@ | ||
<?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 | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Simps\MQTT\Message; | ||
|
||
use Simps\MQTT\Hex\ReasonCode; | ||
use Simps\MQTT\Protocol\Types; | ||
use Simps\MQTT\Protocol\V5; | ||
|
||
class Auth extends AbstractMessage | ||
{ | ||
protected $code = ReasonCode::SUCCESS; | ||
|
||
public function getCode(): int | ||
{ | ||
return $this->code; | ||
} | ||
|
||
public function setCode(int $code): self | ||
{ | ||
$this->code = $code; | ||
|
||
return $this; | ||
} | ||
|
||
// AUTH type is only available in MQTT5 | ||
public function getContents(bool $getArray = false) | ||
{ | ||
$buffer = [ | ||
'type' => Types::AUTH, | ||
'code' => $this->getCode(), | ||
'properties' => $this->getProperties(), | ||
]; | ||
|
||
if ($getArray) { | ||
return $buffer; | ||
} | ||
|
||
return V5::pack($buffer); | ||
} | ||
} |