108. not available
dgastudio opened this issue · comments
Hello
require DRUPAL_ROOT . '/sites/all/libraries/centrifugo/vendor/autoload.php';
$client = new \phpcent\Client('https://****:8000/api');
$client->setApiKey('****');
$channel = 'core';
$data = [
'action' => 'notification',
'data' => [
'type' => 'warning',
'title' => ' title',
'content' => 'content',
'duration' => 10000,
],
];
$client->publish($channel, $data);
works fine (only I do not like the delay of almost a second for the server response)
just after
print_r($client->history($channel));
print_r($client->presence($channel));
for both requests, server returns 108, not available
@dgastudio hello
By default, presence and history features are disabled. See https://centrifugal.github.io/centrifugo/server/channels/#channel-options for channel options which allow to turn them on.
For example add this to your config:
{
"history_size": 100,
"history_lifetime": 300,
"presence": true
}
This will enable both history and presence for channels without namespace. But I recommend using namespaces when enabling features. See https://centrifugal.github.io/centrifugo/faq/#whats-the-best-way-to-organize-channel-configuration
Fine! Many thanks!
now i can check if the user is in the channel before the ws message and if he is offline i will send him a push notification instead
Welcome!
You should be aware of the fact that your approach is racy – since there is a gap in time between check and sending. As I pointed before the correct way to work with push notifications described here. And you better always send messages to WebSocket, without trying to do this based on online status.