We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
1 | <?php |
||
11 | class Centrifuge implements CentrifugeInterface |
||
12 | { |
||
13 | const API_PATH = '/api'; |
||
14 | |||
15 | /** |
||
16 | * @var \GuzzleHttp\Client |
||
17 | */ |
||
18 | protected $httpClient; |
||
19 | |||
20 | /** |
||
21 | * @var array |
||
22 | */ |
||
23 | protected $config; |
||
24 | |||
25 | /** |
||
26 | * Create a new Centrifuge instance. |
||
27 | * |
||
28 | * @param array $config |
||
29 | * @param \GuzzleHttp\Client $httpClient |
||
30 | */ |
||
31 | public function __construct(array $config, HttpClient $httpClient) |
||
36 | |||
37 | /** |
||
38 | * Init Centrifuge configuration. |
||
39 | * |
||
40 | * @param array $config |
||
41 | * @return array |
||
42 | */ |
||
43 | protected function initConfiguration(array $config) |
||
61 | |||
62 | /** |
||
63 | * Send message into channel. |
||
64 | * |
||
65 | * @param string $channel |
||
66 | * @param array $data |
||
67 | * @return mixed |
||
68 | */ |
||
69 | public function publish(string $channel, array $data) |
||
76 | |||
77 | /** |
||
78 | * Send message into multiple channel. |
||
79 | * |
||
80 | * @param array $channels |
||
81 | * @param array $data |
||
82 | * @return mixed |
||
83 | */ |
||
84 | public function broadcast(array $channels, array $data) |
||
90 | |||
91 | /** |
||
92 | * Get channel presence information (all clients currently subscribed on this channel). |
||
93 | * |
||
94 | * @param string $channel |
||
95 | * @return mixed |
||
96 | */ |
||
97 | public function presence(string $channel) |
||
101 | |||
102 | /** |
||
103 | * Get channel presence information in short form. |
||
104 | * |
||
105 | * @param string $channel |
||
106 | * @return mixed |
||
107 | */ |
||
108 | public function presenceStats(string $channel) |
||
112 | |||
113 | /** |
||
114 | * Get channel history information (list of last messages sent into channel). |
||
115 | * |
||
116 | * @param string $channel |
||
117 | * @return mixed |
||
118 | */ |
||
119 | public function history(string $channel) |
||
123 | |||
124 | /** |
||
125 | * Remove channel history information. |
||
126 | * |
||
127 | * @param string $channel |
||
128 | * @return mixed |
||
129 | */ |
||
130 | public function historyRemove(string $channel) |
||
136 | |||
137 | /** |
||
138 | * Unsubscribe user from channel. |
||
139 | * |
||
140 | * @param string $channel |
||
141 | * @param string $user |
||
142 | * @return mixed |
||
143 | */ |
||
144 | public function unsubscribe(string $channel, string $user) |
||
151 | |||
152 | /** |
||
153 | * Disconnect user by its ID. |
||
154 | * |
||
155 | * @param string $user_id |
||
156 | * @return mixed |
||
157 | */ |
||
158 | public function disconnect(string $user_id) |
||
162 | |||
163 | /** |
||
164 | * Get channels information (list of currently active channels). |
||
165 | * |
||
166 | * @return mixed |
||
167 | */ |
||
168 | public function channels() |
||
172 | |||
173 | /** |
||
174 | * Get stats information about running server nodes. |
||
175 | * |
||
176 | * @return mixed |
||
177 | */ |
||
178 | public function info() |
||
182 | |||
183 | /** |
||
184 | * Generate connection token. |
||
185 | * |
||
186 | * @param string $userId |
||
187 | * @param int $exp |
||
188 | * @param array $info |
||
189 | * @return string |
||
190 | */ |
||
191 | public function generateConnectionToken(string $userId = '', int $exp = 0, array $info = []): string |
||
210 | |||
211 | /** |
||
212 | * Generate private channel token. |
||
213 | * |
||
214 | * @param string $client |
||
215 | * @param string $channel |
||
216 | * @param int $exp |
||
217 | * @param array $info |
||
218 | * @return string |
||
219 | */ |
||
220 | public function generatePrivateChannelToken(string $client, string $channel, int $exp = 0, array $info = []): string |
||
239 | |||
240 | /** |
||
241 | * Get secret key. |
||
242 | * |
||
243 | * @return string |
||
244 | */ |
||
245 | protected function getSecret() |
||
249 | |||
250 | /** |
||
251 | * Send message to Centrifuge server. |
||
252 | * |
||
253 | * @param string $method |
||
254 | * @param array $params |
||
255 | * @return mixed |
||
256 | */ |
||
257 | protected function send($method, array $params = []) |
||
296 | |||
297 | /** |
||
298 | * Prepare URL to send the http request. |
||
299 | * |
||
300 | * @return string |
||
301 | */ |
||
302 | protected function prepareUrl() |
||
313 | |||
314 | /** |
||
315 | * Safely encode string in base64. |
||
316 | * @param string $input |
||
317 | * @return string |
||
318 | */ |
||
319 | private function urlsafeB64Encode($input) |
||
323 | |||
324 | /** |
||
325 | * Sign message with secret key. |
||
326 | * @param string $msg |
||
327 | * @param string $key |
||
328 | * @return string |
||
329 | */ |
||
330 | private function sign($msg, $key) |
||
334 | } |
||
335 |