1 | <?php |
||
37 | class Teamspeak3 extends Protocol |
||
38 | { |
||
39 | |||
40 | /** |
||
41 | * Array of packets we want to look up. |
||
42 | * Each key should correspond to a defined method in this or a parent class |
||
43 | * |
||
44 | * @type array |
||
45 | */ |
||
46 | protected $packets = [ |
||
47 | self::PACKET_DETAILS => "use port=%d\x0Aserverinfo\x0A", |
||
48 | self::PACKET_PLAYERS => "use port=%d\x0Aclientlist\x0A", |
||
49 | self::PACKET_CHANNELS => "use port=%d\x0Achannellist -topic\x0A", |
||
50 | ]; |
||
51 | |||
52 | /** |
||
53 | * The transport mode for this protocol is TCP |
||
54 | * |
||
55 | * @type string |
||
56 | */ |
||
57 | protected $transport = self::TRANSPORT_TCP; |
||
58 | |||
59 | /** |
||
60 | * The query protocol used to make the call |
||
61 | * |
||
62 | * @type string |
||
63 | */ |
||
64 | protected $protocol = 'teamspeak3'; |
||
65 | |||
66 | /** |
||
67 | * String name of this protocol class |
||
68 | * |
||
69 | * @type string |
||
70 | */ |
||
71 | protected $name = 'teamspeak3'; |
||
72 | |||
73 | /** |
||
74 | * Longer string name of this protocol class |
||
75 | * |
||
76 | * @type string |
||
77 | */ |
||
78 | protected $name_long = "Teamspeak 3"; |
||
79 | |||
80 | /** |
||
81 | * The client join link |
||
82 | * |
||
83 | * @type string |
||
84 | */ |
||
85 | protected $join_link = "ts3server://%s?port=%d"; |
||
86 | |||
87 | /** |
||
88 | * Normalize settings for this protocol |
||
89 | * |
||
90 | * @type array |
||
91 | */ |
||
92 | protected $normalize = [ |
||
93 | // General |
||
94 | 'general' => [ |
||
95 | 'dedicated' => 'dedicated', |
||
96 | 'hostname' => 'virtualserver_name', |
||
97 | 'password' => 'virtualserver_flag_password', |
||
98 | 'numplayers' => 'numplayers', |
||
99 | 'maxplayers' => 'virtualserver_maxclients', |
||
100 | ], |
||
101 | // Player |
||
102 | 'player' => [ |
||
103 | 'id' => 'clid', |
||
104 | 'team' => 'cid', |
||
105 | 'name' => 'client_nickname', |
||
106 | ], |
||
107 | // Team |
||
108 | 'team' => [ |
||
109 | 'id' => 'cid', |
||
110 | 'name' => 'channel_name', |
||
111 | ], |
||
112 | ]; |
||
113 | |||
114 | /** |
||
115 | * Before we send off the queries we need to update the packets |
||
116 | * |
||
117 | * @param \GameQ\Server $server |
||
118 | * |
||
119 | * @throws \GameQ\Exception\Protocol |
||
120 | */ |
||
121 | 5 | public function beforeSend(Server $server) |
|
137 | |||
138 | /** |
||
139 | * Process the response |
||
140 | * |
||
141 | * @return array |
||
142 | * @throws \GameQ\Exception\Protocol |
||
143 | */ |
||
144 | 3 | public function processResponse() |
|
209 | |||
210 | /* |
||
211 | * Internal methods |
||
212 | */ |
||
213 | |||
214 | /** |
||
215 | * Process the properties of the data. |
||
216 | * |
||
217 | * Takes data in "key1=value1 key2=value2 ..." and processes it into a usable format |
||
218 | * |
||
219 | * @param $data |
||
220 | * |
||
221 | * @return array |
||
222 | */ |
||
223 | protected function processProperties($data) |
||
251 | |||
252 | /** |
||
253 | * Handles processing the details data into a usable format |
||
254 | * |
||
255 | * @param string $data |
||
256 | * @param \GameQ\Result $result |
||
257 | */ |
||
258 | protected function processDetails($data, Result &$result) |
||
280 | |||
281 | /** |
||
282 | * Process the channel listing |
||
283 | * |
||
284 | * @param string $data |
||
285 | * @param \GameQ\Result $result |
||
286 | */ |
||
287 | protected function processChannels($data, Result &$result) |
||
306 | |||
307 | /** |
||
308 | * Process the user listing |
||
309 | * |
||
310 | * @param string $data |
||
311 | * @param \GameQ\Result $result |
||
312 | */ |
||
313 | protected function processPlayers($data, Result &$result) |
||
332 | } |
||
333 |