Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

broadcast package #42

Merged
merged 38 commits into from
Feb 17, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
a940620
[WIP]
Nov 14, 2024
65696e9
[WIP]
Nov 14, 2024
76fa551
complete broadcaster
Nov 15, 2024
b4cf9ce
fix cs
Nov 15, 2024
330e75e
phpstan fix
Nov 15, 2024
bb905f6
fix cs
Nov 15, 2024
d7a09b6
[WIP]
Nov 16, 2024
69a1cb1
add AblyBroadcaster
Nov 18, 2024
5613734
fix cs
Nov 18, 2024
825da02
phpstan fix
Nov 18, 2024
a9429cb
add PusherBroadcaster
Nov 18, 2024
746ee43
phpstan fix
Nov 18, 2024
6138743
add RedisBroadcaster
Nov 18, 2024
f05425c
fix cs
Nov 18, 2024
c6830a1
remove useless code
Nov 18, 2024
fadff95
add Channels and BroadcastEvent
Nov 19, 2024
ba83fe3
add contracts
Nov 19, 2024
7d2c078
add InteractsWithSockets, UniqueBroadcastEven
Nov 19, 2024
eafb31d
don't depend on container of SwoolTW, instead depend on Psr7 container
Nov 19, 2024
370df40
[WIP]
Nov 19, 2024
81c1593
[WIP]
Nov 20, 2024
2a8148e
add integration test
Nov 21, 2024
02b99e8
cx fix
Nov 21, 2024
6e6ecb8
add SendingBroadcastsViaAnonymousEventTest
Nov 21, 2024
be5f3ed
fix test
Nov 21, 2024
e3de47f
remove route binding code
Nov 21, 2024
05b4b51
dispatch broadcaster
Nov 21, 2024
b113bb7
add require package and remove useless code
Nov 21, 2024
9b34d29
fix
Nov 22, 2024
5eeafd1
Merge branch 'master' into feature/broadcast
Jan 3, 2025
f444b3b
add queue
Jan 3, 2025
8cb3824
Merge branch 'master' into feature/broadcast
Jan 10, 2025
99757cd
Merge branch 'master' into feature/broadcast
Feb 13, 2025
40b7504
use function namespace, bind BroadcastManager directly, don't use alias
Feb 13, 2025
800d398
fix
Feb 17, 2025
e2bfbaa
Merge branch 'master' into feature/broadcast
albertcht Feb 17, 2025
539821d
improve: improve routes in BroadcastManager
albertcht Feb 17, 2025
dbaa0c6
feat: enable broadcast field in EventWatcher
albertcht Feb 17, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
use function namespace, bind BroadcastManager directly, don't use alias
name
  • Loading branch information
Yu Shing committed Feb 13, 2025
commit 40b7504d48ca5e4e899f02648cf36813ebd1984b
2 changes: 2 additions & 0 deletions src/broadcasting/src/AnonymousEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
use SwooleTW\Hyperf\Broadcasting\Contracts\ShouldBroadcast;
use SwooleTW\Hyperf\Foundation\Events\Dispatchable;

use function Hyperf\Collection\collect;

class AnonymousEvent implements ShouldBroadcast
{
use Dispatchable;
Expand Down
9 changes: 6 additions & 3 deletions src/broadcasting/src/BroadcastManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
use SwooleTW\Hyperf\Bus\UniqueLock;
use SwooleTW\Hyperf\Cache\Contracts\Factory as Cache;
use SwooleTW\Hyperf\ObjectPool\Traits\HasPoolProxy;
use SwooleTW\Hyperf\Queue\Contracts\Factory as Queue;

/**
* @mixin Broadcaster
Expand Down Expand Up @@ -68,9 +69,11 @@ public function __construct(
/**
* Register the routes for handling broadcast channel authentication and sockets.
*/
public function routes(?array $attributes = null): void
public function routes(array $attributes = []): void
{
$attributes = $attributes ?: ['middleware' => ['web']];
if (class_exists('SwooleTW\Hyperf\Foundation\Http\Kernel')) {
$attributes = $attributes ?: ['middleware' => ['web']];
}

$this->app->get(RouterDispatcherFactory::class)->getRouter()
->addRoute(
Expand Down Expand Up @@ -181,7 +184,7 @@ public function queue(mixed $event): void
}
}

$this->app->get('queue')
$this->app->get(Queue::class)
->connection($event->connection ?? null)
->pushOn($queue, $broadcastEvent);
}
Expand Down
2 changes: 2 additions & 0 deletions src/broadcasting/src/Broadcasters/AblyBroadcaster.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
use SwooleTW\Hyperf\Broadcasting\BroadcastException;
use SwooleTW\Hyperf\HttpMessage\Exceptions\AccessDeniedHttpException;

use function Hyperf\Tappable\tap;

class AblyBroadcaster extends Broadcaster
{
/**
Expand Down
3 changes: 1 addition & 2 deletions src/broadcasting/src/ConfigProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

namespace SwooleTW\Hyperf\Broadcasting;

use Psr\Container\ContainerInterface;
use SwooleTW\Hyperf\Broadcasting\Contracts\Factory;

class ConfigProvider
Expand All @@ -13,7 +12,7 @@ public function __invoke(): array
{
return [
'dependencies' => [
Factory::class => fn (ContainerInterface $container) => new BroadcastManager($container),
Factory::class => BroadcastManager::class,
],
];
}
Expand Down