PocketMine-MP 5.21.2 git-a6534ecbbbcf369264567d27e5ed70f7f5be9816
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
26 public static function toString(int $reason) : string{
27 return match($reason){
28 self::CLIENT_DISCONNECT => "client disconnect",
29 self::SERVER_DISCONNECT => "server disconnect",
30 self::PEER_TIMEOUT => "timeout",
31 self::CLIENT_RECONNECT => "new session established on same address and port",
32 self::SERVER_SHUTDOWN => "server shutdown",
33 default => "Unknown reason $reason"
34 };
35 }
36}