PocketMine-MP 5.27.2 git-d86943fa8c6384be3e2c1901ebf94f584b27e784
Loading...
Searching...
No Matches
DisconnectReason.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\generic;
18
19final class DisconnectReason{
20 public const CLIENT_DISCONNECT = 0;
21 public const SERVER_DISCONNECT = 1;
22 public const PEER_TIMEOUT = 2;
23 public const CLIENT_RECONNECT = 3;
24 public const SERVER_SHUTDOWN = 4; //TODO: do we really need a separate reason for this in addition to SERVER_DISCONNECT?
25 public const SPLIT_PACKET_TOO_LARGE = 5;
26 public const SPLIT_PACKET_TOO_MANY_CONCURRENT = 6;
27 public const SPLIT_PACKET_INVALID_PART_INDEX = 7;
28 public const SPLIT_PACKET_INCONSISTENT_HEADER = 8;
29
30 public static function toString(int $reason) : string{
31 return match($reason){
32 self::CLIENT_DISCONNECT => "client disconnect",
33 self::SERVER_DISCONNECT => "server disconnect",
34 self::PEER_TIMEOUT => "timeout",
35 self::CLIENT_RECONNECT => "new session established on same address and port",
36 self::SERVER_SHUTDOWN => "server shutdown",
37 self::SPLIT_PACKET_TOO_LARGE => "received packet split into more parts than allowed",
38 self::SPLIT_PACKET_TOO_MANY_CONCURRENT => "too many received split packets being reassembled at once",
39 self::SPLIT_PACKET_INVALID_PART_INDEX => "invalid split packet part index",
40 self::SPLIT_PACKET_INCONSISTENT_HEADER => "received split packet header inconsistent with previous fragments",
41 default => "Unknown reason $reason"
42 };
43 }
44}