1 | <?php |
||
18 | class Quake2 extends Protocol |
||
19 | { |
||
20 | /** |
||
21 | * Array of packets we want to look up. |
||
22 | * Each key should correspond to a defined method in this or a parent class |
||
23 | * |
||
24 | * @type array |
||
25 | */ |
||
26 | protected $packets = [ |
||
27 | self::PACKET_STATUS => "\xFF\xFF\xFF\xFFstatus\x00", |
||
28 | ]; |
||
29 | |||
30 | /** |
||
31 | * Use the response flag to figure out what method to run |
||
32 | * |
||
33 | * @type array |
||
34 | */ |
||
35 | protected $responses = [ |
||
36 | "\xFF\xFF\xFF\xFF\x70\x72\x69\x6e\x74" => 'processStatus', |
||
37 | ]; |
||
38 | |||
39 | /** |
||
40 | * The query protocol used to make the call |
||
41 | * |
||
42 | * @type string |
||
43 | */ |
||
44 | protected $protocol = 'quake2'; |
||
45 | |||
46 | /** |
||
47 | * String name of this protocol class |
||
48 | * |
||
49 | * @type string |
||
50 | */ |
||
51 | protected $name = 'quake2'; |
||
52 | |||
53 | /** |
||
54 | * Longer string name of this protocol class |
||
55 | * |
||
56 | * @type string |
||
57 | */ |
||
58 | protected $name_long = "Quake 2 Server"; |
||
59 | |||
60 | /** |
||
61 | * The client join link |
||
62 | * |
||
63 | * @type string |
||
64 | */ |
||
65 | protected $join_link = null; |
||
66 | |||
67 | /** |
||
68 | * Normalize settings for this protocol |
||
69 | * |
||
70 | * @type array |
||
71 | */ |
||
72 | protected $normalize = [ |
||
73 | // General |
||
74 | 'general' => [ |
||
75 | // target => source |
||
76 | 'gametype' => 'gamename', |
||
77 | 'hostname' => 'hostname', |
||
78 | 'mapname' => 'mapname', |
||
79 | 'maxplayers' => 'maxclients', |
||
80 | 'mod' => 'g_gametype', |
||
81 | 'numplayers' => 'clients', |
||
82 | 'password' => 'password', |
||
83 | ], |
||
84 | // Individual |
||
85 | 'player' => [ |
||
86 | 'name' => 'name', |
||
87 | 'ping' => 'ping', |
||
88 | 'score' => 'frags', |
||
89 | ], |
||
90 | ]; |
||
91 | |||
92 | /** |
||
93 | * Handle response from the server |
||
94 | * |
||
95 | * @return mixed |
||
96 | * @throws Exception |
||
97 | */ |
||
98 | 5 | public function processResponse() |
|
113 | |||
114 | /** |
||
115 | * Process the status response |
||
116 | * |
||
117 | * @param Buffer $buffer |
||
118 | * |
||
119 | * @return array |
||
120 | */ |
||
121 | 3 | protected function processStatus(Buffer $buffer) |
|
136 | |||
137 | /** |
||
138 | * Handle processing the server information |
||
139 | * |
||
140 | * @param Buffer $buffer |
||
141 | * |
||
142 | * @return array |
||
143 | */ |
||
144 | 3 | protected function processServerInfo(Buffer $buffer) |
|
168 | |||
169 | /** |
||
170 | * Handle processing of player data |
||
171 | * |
||
172 | * @param Buffer $buffer |
||
173 | * |
||
174 | * @return array |
||
175 | */ |
||
176 | 3 | protected function processPlayers(Buffer $buffer) |
|
219 | } |
||
220 |