1 | <?php |
||
35 | class Gamespy2 extends Protocol |
||
36 | { |
||
37 | |||
38 | /** |
||
39 | * Define the state of this class |
||
40 | * |
||
41 | * @type int |
||
42 | */ |
||
43 | protected $state = self::STATE_BETA; |
||
44 | |||
45 | /** |
||
46 | * Array of packets we want to look up. |
||
47 | * Each key should correspond to a defined method in this or a parent class |
||
48 | * |
||
49 | * @type array |
||
50 | */ |
||
51 | protected $packets = [ |
||
52 | self::PACKET_DETAILS => "\xFE\xFD\x00\x43\x4F\x52\x59\xFF\x00\x00", |
||
53 | self::PACKET_PLAYERS => "\xFE\xFD\x00\x43\x4F\x52\x58\x00\xFF\xFF", |
||
54 | ]; |
||
55 | |||
56 | /** |
||
57 | * Use the response flag to figure out what method to run |
||
58 | * |
||
59 | * @type array |
||
60 | */ |
||
61 | protected $responses = [ |
||
62 | "\x00\x43\x4F\x52\x59" => "processDetails", |
||
63 | "\x00\x43\x4F\x52\x58" => "processPlayers", |
||
64 | ]; |
||
65 | |||
66 | /** |
||
67 | * The query protocol used to make the call |
||
68 | * |
||
69 | * @type string |
||
70 | */ |
||
71 | protected $protocol = 'gamespy2'; |
||
72 | |||
73 | /** |
||
74 | * String name of this protocol class |
||
75 | * |
||
76 | * @type string |
||
77 | */ |
||
78 | protected $name = 'gamespy2'; |
||
79 | |||
80 | /** |
||
81 | * Longer string name of this protocol class |
||
82 | * |
||
83 | * @type string |
||
84 | */ |
||
85 | protected $name_long = "GameSpy2 Server"; |
||
86 | |||
87 | /** |
||
88 | * The client join link |
||
89 | * |
||
90 | * @type string |
||
91 | */ |
||
92 | protected $join_link = null; |
||
93 | |||
94 | /** |
||
95 | * Normalize settings for this protocol |
||
96 | * |
||
97 | * @type array |
||
98 | */ |
||
99 | protected $normalize = [ |
||
100 | // General |
||
101 | 'general' => [ |
||
102 | // target => source |
||
103 | 'dedicated' => 'dedicated', |
||
104 | 'gametype' => 'gametype', |
||
105 | 'hostname' => 'hostname', |
||
106 | 'mapname' => 'mapname', |
||
107 | 'maxplayers' => 'maxplayers', |
||
108 | 'mod' => 'mod', |
||
109 | 'numplayers' => 'numplayers', |
||
110 | 'password' => 'password', |
||
111 | ], |
||
112 | ]; |
||
113 | |||
114 | |||
115 | /** |
||
116 | * Process the response |
||
117 | * |
||
118 | * @return array |
||
119 | * @throws Exception |
||
120 | */ |
||
121 | public function processResponse() |
||
160 | |||
161 | /* |
||
162 | * Internal methods |
||
163 | */ |
||
164 | |||
165 | /** |
||
166 | * Handles processing the details data into a usable format |
||
167 | * |
||
168 | * @param \GameQ\Buffer $buffer |
||
169 | * |
||
170 | * @return array |
||
171 | * @throws Exception |
||
172 | */ |
||
173 | protected function processDetails(Buffer $buffer) |
||
192 | |||
193 | /** |
||
194 | * Handles processing the players data into a usable format |
||
195 | * |
||
196 | * @param \GameQ\Buffer $buffer |
||
197 | * |
||
198 | * @return array |
||
199 | * @throws Exception |
||
200 | */ |
||
201 | protected function processPlayers(Buffer $buffer) |
||
220 | |||
221 | /** |
||
222 | * Parse the player/team info returned from the player call |
||
223 | * |
||
224 | * @param string $dataType |
||
225 | * @param \GameQ\Buffer $buffer |
||
226 | * @param \GameQ\Result $result |
||
227 | * |
||
228 | * @throws Exception |
||
229 | */ |
||
230 | protected function parsePlayerTeam($dataType, Buffer &$buffer, Result &$result) |
||
269 | } |
||
270 |