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

Remove dependencies #15

Merged
merged 35 commits into from
Nov 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
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
12 changes: 7 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,24 @@
"require": {
"php": "^8.2",
"aws/aws-sdk-php": "^3.241",
"cboden/ratchet": "^0.4.4",
"clue/redis-react": "^2.6",
"guzzlehttp/psr7": "^2.6",
"illuminate/cache": "^10.0",
"illuminate/console": "^10.0",
"illuminate/http": "^10.0",
"illuminate/redis": "^10.0",
"illuminate/support": "^10.0",
"nesbot/carbon": "^2.64"
"nesbot/carbon": "^2.64",
"ratchet/rfc6455": "^0.3.1",
"react/socket": "^1.14",
"symfony/http-foundation": "^6.3"
},
"require-dev": {
"orchestra/testbench": "^8.0",
"pestphp/pest": "^2.0",
"phpstan/phpstan": "^1.10",
"ratchet/pawl": "^0.4.1",
"react/async": "^4.0",
"react/http": "^1.8"
"react/async": "^4.0"
},
"autoload": {
"psr-4": {
Expand Down Expand Up @@ -66,4 +68,4 @@
},
"minimum-stability": "dev",
"prefer-stable": true
}
}
16 changes: 8 additions & 8 deletions config/reverb.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
| messages received from and when sending messages to connected
| clients. You must specify one of the servers listed below.
|
| Supported: "ratchet", "api_gateway"
| Supported: "reverb", "api_gateway"
*/

'default' => env('REVERB_SERVER', 'ratchet'),
'default' => env('REVERB_SERVER', 'reverb'),

/*
|--------------------------------------------------------------------------
Expand All @@ -28,15 +28,15 @@

'servers' => [

'ratchet' => [
'host' => env('REVERB_RATCHET_HOST', '127.0.0.1'),
'port' => env('REVERB_RATCHET_PORT', 8080),
'reverb' => [
'host' => env('REVERB_HOST', '127.0.0.1'),
'port' => env('REVERB_PORT', 8080),
'connection_manager' => [
'prefix' => env('REVERB_RATCHET_CONNECTION_CACHE_PREFIX', 'reverb'),
'prefix' => env('REVERB_CONNECTION_CACHE_PREFIX', 'reverb'),
],
'publish_events' => [
'enabled' => env('REVERB_RATCHET_SCALING_ENABLED', false),
'channel' => env('REVERB_RATCHET_SCALING_CHANNEL', 'reverb'),
'enabled' => env('REVERB_SCALING_ENABLED', false),
'channel' => env('REVERB_SCALING_CHANNEL', 'reverb'),
],
],

Expand Down
6 changes: 2 additions & 4 deletions src/Channels/Channel.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
use Illuminate\Support\Arr;
use Illuminate\Support\Facades\App;
use Laravel\Reverb\Application;
use Laravel\Reverb\Connection;
use Laravel\Reverb\Contracts\ChannelManager;
use Laravel\Reverb\Contracts\Connection;
use Laravel\Reverb\Output;

class Channel
Expand Down Expand Up @@ -49,9 +49,7 @@ public function unsubscribe(Connection $connection): void
*/
public function broadcast(Application $app, array $payload, Connection $except = null): void
{
App::make(ChannelManager::class)
->for($app)
->connections($this)
collect(App::make(ChannelManager::class)->for($app)->connections($this))
->each(function ($connection) use ($payload, $except) {
if ($except && $except->identifier() === $connection->identifier()) {
return;
Expand Down
2 changes: 1 addition & 1 deletion src/Channels/PresenceChannel.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

use Illuminate\Support\Facades\App;
use Laravel\Reverb\Application;
use Laravel\Reverb\Connection;
use Laravel\Reverb\Contracts\ChannelManager;
use Laravel\Reverb\Contracts\Connection;

class PresenceChannel extends PrivateChannel
{
Expand Down
2 changes: 1 addition & 1 deletion src/Channels/PrivateChannel.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace Laravel\Reverb\Channels;

use Illuminate\Support\Str;
use Laravel\Reverb\Connection;
use Laravel\Reverb\Contracts\Connection;
use Laravel\Reverb\Exceptions\ConnectionUnauthorized;

class PrivateChannel extends Channel
Expand Down
1 change: 1 addition & 0 deletions src/ClientEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Laravel\Reverb;

use Illuminate\Support\Str;
use Laravel\Reverb\Contracts\Connection;

class ClientEvent
{
Expand Down
21 changes: 21 additions & 0 deletions src/Concerns/ClosesConnections.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

namespace Laravel\Reverb\Concerns;

use GuzzleHttp\Psr7\Message;
use GuzzleHttp\Psr7\Response;
use Laravel\Reverb\Http\Connection;

trait ClosesConnections
{
/**
* Close the connection.
*/
protected function close(Connection $connection, int $statusCode = 400, array $headers = []): void
{
$response = new Response($statusCode, $headers);

$connection->send(Message::toString($response));
$connection->close();
}
}
51 changes: 0 additions & 51 deletions src/Console/Commands/StartServer.php

This file was deleted.

10 changes: 2 additions & 8 deletions src/Contracts/ChannelManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
use Illuminate\Support\Collection;
use Laravel\Reverb\Application;
use Laravel\Reverb\Channels\Channel;
use Laravel\Reverb\Connection;
use Laravel\Reverb\Managers\Connections;

interface ChannelManager
Expand Down Expand Up @@ -40,17 +39,12 @@ public function all(): Collection;
*/
public function unsubscribeFromAll(Connection $connection): void;

/**
* Get all connection keys for the given channel.
*/
public function connectionKeys(Channel $channel): Collection;

/**
* Get all connections for the given channel.
*
* @return \Laravel\Reverb\Managers\Connections|\Laravel\Reverb\Connection[]|string[]
* @return <array string, \Laravel\Reverb\Connection>
*/
public function connections(Channel $channel): Connections;
public function connections(Channel $channel): array;

/**
* Flush the channel manager repository.
Expand Down
8 changes: 4 additions & 4 deletions src/Connection.php → src/Contracts/Connection.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<?php

namespace Laravel\Reverb;
namespace Laravel\Reverb\Contracts;

use Carbon\Carbon;
use Illuminate\Support\Facades\App;
use Laravel\Reverb\Contracts\ChannelManager;
use Laravel\Reverb\Contracts\ConnectionManager;
use Laravel\Reverb\Contracts\SerializableConnection;
use Laravel\Reverb\Application;
use Laravel\Reverb\Output;
use Laravel\Reverb\PusherEvent;

abstract class Connection
{
Expand Down
14 changes: 3 additions & 11 deletions src/Contracts/ConnectionManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

use Closure;
use Laravel\Reverb\Application;
use Laravel\Reverb\Connection;
use Laravel\Reverb\Managers\Connections;

interface ConnectionManager
Expand Down Expand Up @@ -47,21 +46,14 @@ public function find(string $identifier): ?Connection;
/**
* Get all of the connections from the cache.
*
* @return \Laravel\Reverb\Managers\Connections|\Laravel\Reverb\Connection[]|string[]
* @return <int, \Laravel\Reverb\Connection>
*/
public function all(): Connections;

/**
* Synchronize the connections with the manager.
*
* @param \Laravel\Reverb\Managers\Connections|\Laravel\Reverb\Connection[]|string[] $connections
*/
public function sync(Connections $connections): void;
public function all(): array;

/**
* Synchronize a connection with the manager.
*/
public function syncConnection(Connection $connection): void;
public function save(Connection $connection): void;

/**
* Flush the channel manager repository.
Expand Down
1 change: 1 addition & 0 deletions src/Event.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Illuminate\Support\Facades\App;
use Laravel\Reverb\Channels\ChannelBroker;
use Laravel\Reverb\Contracts\Connection;
use Laravel\Reverb\Contracts\ServerProvider;

class Event
Expand Down
Loading