Skip to content

Commit

Permalink
Refactored internet time option to sync server time as per review com…
Browse files Browse the repository at this point in the history
…ment
  • Loading branch information
sacOO7 committed Nov 30, 2022
1 parent 19e16da commit 9ab257d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -152,16 +152,16 @@ npm run dev
**4. Use internet time for issued token expiry. Default: false**
- If this option is enabled, internet time in UTC format is fetched from the Ably service and cached every 6 hrs.
- This option is useful when using laravel-broadcaster on a server where, for some reason, the server clock cannot be kept synchronized through normal means.
- Set `ABLY_USE_INTERNET_TIME` as **true** in **.env** file.
- Set `ABLY_SYNC_SERVER_TIME` as **true** in **.env** file.
```dotenv
ABLY_USE_INTERNET_TIME=true
ABLY_SYNC_SERVER_TIME=true
```
- Update ably section under `config/broadcasting.php` with
```php
'ably' => [
'driver' => 'ably',
'key' => env('ABLY_KEY'),
'use_internet_time' => env('ABLY_USE_INTERNET_TIME', false)
'sync_server_time' => env('ABLY_SYNC_SERVER_TIME', false)
],
```

Expand Down
2 changes: 1 addition & 1 deletion src/AblyBroadcaster.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public function __construct(AblyRest $ably, $config)
{
$this->ably = $ably;

if (array_key_exists('use_internet_time', $config) && $config['use_internet_time']) {
if (array_key_exists('sync_server_time', $config) && $config['sync_server_time']) {
// Local file cache is preferred to avoid sharing serverTimeDiff across different servers
$this->serverTimeDiff = Cache::store('file')->remember('ably_server_time_diff', 6 * 3600, function() {
return time() - round($this->ably->time() / 1000);
Expand Down

0 comments on commit 9ab257d

Please sign in to comment.