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