PocketMine-MP 5.18.2 git-00e39821f06a4b6d728d35053c2621dbb19369ff
OpenConnectionReply1.php
1<?php
2
3/*
4 * This file is part of RakLib.
5 * Copyright (C) 2014-2022 PocketMine Team <https://github.com/pmmp/RakLib>
6 *
7 * RakLib is not affiliated with Jenkins Software LLC nor RakNet.
8 *
9 * RakLib is free software: you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation, either version 3 of the License, or
12 * (at your option) any later version.
13 */
14
15declare(strict_types=1);
16
17namespace raklib\protocol;
18
21
22 public int $serverID;
23 public bool $serverSecurity = false;
24 public int $mtuSize;
25
26 public static function create(int $serverId, bool $serverSecurity, int $mtuSize) : self{
27 $result = new self;
28 $result->serverID = $serverId;
29 $result->serverSecurity = $serverSecurity;
30 $result->mtuSize = $mtuSize;
31 return $result;
32 }
33
34 protected function encodePayload(PacketSerializer $out) : void{
35 $this->writeMagic($out);
36 $out->putLong($this->serverID);
37 $out->putByte($this->serverSecurity ? 1 : 0);
38 $out->putShort($this->mtuSize);
39 }
40
41 protected function decodePayload(PacketSerializer $in) : void{
42 $this->readMagic($in);
43 $this->serverID = $in->getLong();
44 $this->serverSecurity = $in->getByte() !== 0;
45 $this->mtuSize = $in->getShort();
46 }
47}