Skip to content

Commit

Permalink
fix: update polling interval to milliseconds
Browse files Browse the repository at this point in the history
  • Loading branch information
jshah4517 committed Jun 29, 2021
1 parent 449cf14 commit 056299c
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,6 @@ window.Echo = new Echo({
subscribe: "{{ route('supportpal.pollcast.subscribe') }}",
unsubscribe: "{{ route('supportpal.pollcast.unsubscribe') }}"
},
polling: "{{ config('pollcast.polling_interval') }}"
polling: {{ Config.get('pollcast.polling_interval', 5000) }}
});
```
8 changes: 4 additions & 4 deletions config/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
| Polling Interval
|--------------------------------------------------------------------------
|
| Here you may specify how often the polling for new messages occurs, we
| recommend a low value to better replicate how a web-sockets environment
| would work.
| Here you may specify how often the polling for new messages occurs in
| milliseconds, we recommend a low value to better replicate how a
| web sockets environment would work.
|
*/
'polling_interval' => 5,
'polling_interval' => 5000,

/*
|--------------------------------------------------------------------------
Expand Down
6 changes: 3 additions & 3 deletions src/PollcastBroadcaster.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,15 +114,15 @@ protected function gc(): void
->where('updated_at', '<', Carbon::now()->subDay()->toDateTimeString())
->delete();

$pollingInterval = (int) config('pollcast.polling_interval', 5);
$pollingInterval = (int) config('pollcast.polling_interval', 5000);

Message::query()
->where('created_at', '<', Carbon::now()->subSeconds($pollingInterval * 6)->toDateTimeString())
->where('created_at', '<', Carbon::now()->subMilliseconds($pollingInterval * 6)->toDateTimeString())
->delete();

Member::query()
->with('channel')
->where('updated_at', '<', Carbon::now()->subSeconds($pollingInterval * 6)->toDateTimeString())
->where('updated_at', '<', Carbon::now()->subMilliseconds($pollingInterval * 6)->toDateTimeString())
->each(function (Member $member) {
/** @var Channel $channel */
$channel = $member->channel;
Expand Down
2 changes: 1 addition & 1 deletion tests/Unit/PollcastBroadcasterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ public function testBroadcastGarbageCollection(): void

public function testBroadcastGarbageCollectionWithDifferentInterval(): void
{
config(['pollcast.polling_interval' => 10]);
config(['pollcast.polling_interval' => 10000]);

// Update lottery so garbage collection always runs.
config(['pollcast.gc_lottery' => [1, 1]]);
Expand Down

0 comments on commit 056299c

Please sign in to comment.