forked from DiscordBot-PMMP/DiscordBot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDisconnect.php
47 lines (37 loc) · 1.12 KB
/
Disconnect.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<?php
/*
* DiscordBot, PocketMine-MP Plugin.
*
* Licensed under the Open Software License version 3.0 (OSL-3.0)
* Copyright (C) 2020-present JaxkDev
*
* Discord :: JaxkDev
* Email :: JaxkDev@gmail.com
*/
namespace JaxkDev\DiscordBot\Communication\Packets\External;
use JaxkDev\DiscordBot\Communication\BinaryStream;
use JaxkDev\DiscordBot\Communication\Packets\Packet;
final class Disconnect extends Packet{
public const SERIALIZE_ID = 101;
private string $message;
public function __construct(?string $message = null, ?int $uid = null){
parent::__construct($uid);
$this->message = $message ?? "Unknown";
}
public function getMessage(): string{
return $this->message;
}
public function binarySerialize(): BinaryStream{
$stream = new BinaryStream();
$stream->putInt($this->getUID());
$stream->putString($this->message);
return $stream;
}
public static function fromBinary(BinaryStream $stream): self{
$uid = $stream->getInt();
return new self(
$stream->getString(), // message
$uid
);
}
}