Merge branch 'master' of github.com:beyondcode/laravel-websockets
This commit is contained in:
commit
f26f89236e
|
|
@ -27,18 +27,18 @@
|
|||
"cboden/ratchet": "^0.4.1",
|
||||
"clue/buzz-react": "^2.5",
|
||||
"guzzlehttp/psr7": "^1.5",
|
||||
"illuminate/broadcasting": "5.7.*",
|
||||
"illuminate/console": "5.7.*",
|
||||
"illuminate/http": "5.7.*",
|
||||
"illuminate/routing": "5.7.*",
|
||||
"illuminate/support": "5.7.*",
|
||||
"illuminate/broadcasting": "5.7.* || 5.8.*",
|
||||
"illuminate/console": "5.7.* || 5.8.*",
|
||||
"illuminate/http": "5.7.* || 5.8.*",
|
||||
"illuminate/routing": "5.7.* || 5.8.*",
|
||||
"illuminate/support": "5.7.* || 5.8.*",
|
||||
"pusher/pusher-php-server": "~3.0",
|
||||
"symfony/http-kernel": "~4.0",
|
||||
"symfony/psr-http-message-bridge": "^1.1"
|
||||
},
|
||||
"require-dev": {
|
||||
"mockery/mockery": "^1.2",
|
||||
"orchestra/testbench": "3.7.*",
|
||||
"orchestra/testbench": "3.7.* || 3.8.*",
|
||||
"phpunit/phpunit": "^7.0"
|
||||
},
|
||||
"autoload": {
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ namespace BeyondCode\LaravelWebSockets\HttpApi\Controllers;
|
|||
|
||||
use Exception;
|
||||
use Pusher\Pusher;
|
||||
use Illuminate\Support\Arr;
|
||||
use Illuminate\Http\Request;
|
||||
use GuzzleHttp\Psr7\Response;
|
||||
use Ratchet\ConnectionInterface;
|
||||
|
|
@ -43,7 +44,7 @@ abstract class Controller implements HttpServerInterface
|
|||
|
||||
$this->contentLength = $this->findContentLength($request->getHeaders());
|
||||
|
||||
$this->requestBuffer = (string)$request->getBody();
|
||||
$this->requestBuffer = (string) $request->getBody();
|
||||
|
||||
$this->checkContentLength($connection);
|
||||
}
|
||||
|
|
@ -123,7 +124,7 @@ abstract class Controller implements HttpServerInterface
|
|||
*
|
||||
* The `appId`, `appKey` & `channelName` parameters are actually route paramaters and are never supplied by the client.
|
||||
*/
|
||||
$params = array_except($request->query(), ['auth_signature', 'body_md5', 'appId', 'appKey', 'channelName']);
|
||||
$params = Arr::except($request->query(), ['auth_signature', 'body_md5', 'appId', 'appKey', 'channelName']);
|
||||
|
||||
if ($request->getContent() !== '') {
|
||||
$params['body_md5'] = md5($request->getContent());
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace BeyondCode\LaravelWebSockets\HttpApi\Controllers;
|
||||
|
||||
use Illuminate\Support\Str;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Collection;
|
||||
use BeyondCode\LaravelWebSockets\WebSockets\Channels\PresenceChannel;
|
||||
|
|
@ -16,7 +17,7 @@ class FetchChannelsController extends Controller
|
|||
|
||||
if ($request->has('filter_by_prefix')) {
|
||||
$channels = $channels->filter(function ($channel, $channelName) use ($request) {
|
||||
return starts_with($channelName, $request->filter_by_prefix);
|
||||
return Str::startsWith($channelName, $request->filter_by_prefix);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace BeyondCode\LaravelWebSockets\Statistics\Events;
|
||||
|
||||
use Illuminate\Support\Str;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Broadcasting\PrivateChannel;
|
||||
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
|
||||
|
|
@ -33,7 +34,7 @@ class StatisticsUpdated implements ShouldBroadcast
|
|||
|
||||
public function broadcastOn()
|
||||
{
|
||||
$channelName = str_after(DashboardLogger::LOG_CHANNEL_PREFIX.'statistics', 'private-');
|
||||
$channelName = Str::after(DashboardLogger::LOG_CHANNEL_PREFIX.'statistics', 'private-');
|
||||
|
||||
return new PrivateChannel($channelName);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
namespace BeyondCode\LaravelWebSockets\WebSockets\Channels;
|
||||
|
||||
use stdClass;
|
||||
use Illuminate\Support\Str;
|
||||
use Ratchet\ConnectionInterface;
|
||||
use BeyondCode\LaravelWebSockets\Dashboard\DashboardLogger;
|
||||
use BeyondCode\LaravelWebSockets\WebSockets\Exceptions\InvalidSignature;
|
||||
|
|
@ -38,7 +39,7 @@ class Channel
|
|||
$signature .= ":{$payload->channel_data}";
|
||||
}
|
||||
|
||||
if (str_after($payload->auth, ':') !== hash_hmac('sha256', $signature, $connection->app->secret)) {
|
||||
if (Str::after($payload->auth, ':') !== hash_hmac('sha256', $signature, $connection->app->secret)) {
|
||||
throw new InvalidSignature();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
namespace BeyondCode\LaravelWebSockets\WebSockets\Channels\ChannelManagers;
|
||||
|
||||
use Illuminate\Support\Arr;
|
||||
use Illuminate\Support\Str;
|
||||
use Ratchet\ConnectionInterface;
|
||||
use BeyondCode\LaravelWebSockets\WebSockets\Channels\Channel;
|
||||
use BeyondCode\LaravelWebSockets\WebSockets\Channels\ChannelManager;
|
||||
|
|
@ -34,11 +36,11 @@ class ArrayChannelManager implements ChannelManager
|
|||
|
||||
protected function determineChannelClass(string $channelName): string
|
||||
{
|
||||
if (starts_with($channelName, 'private-')) {
|
||||
if (Str::startsWith($channelName, 'private-')) {
|
||||
return PrivateChannel::class;
|
||||
}
|
||||
|
||||
if (starts_with($channelName, 'presence-')) {
|
||||
if (Str::startsWith($channelName, 'presence-')) {
|
||||
return PresenceChannel::class;
|
||||
}
|
||||
|
||||
|
|
@ -67,18 +69,18 @@ class ArrayChannelManager implements ChannelManager
|
|||
/*
|
||||
* Remove the connection from all channels.
|
||||
*/
|
||||
collect(array_get($this->channels, $connection->app->id, []))->each->unsubscribe($connection);
|
||||
collect(Arr::get($this->channels, $connection->app->id, []))->each->unsubscribe($connection);
|
||||
|
||||
/*
|
||||
* Unset all channels that have no connections so we don't leak memory.
|
||||
*/
|
||||
collect(array_get($this->channels, $connection->app->id, []))
|
||||
collect(Arr::get($this->channels, $connection->app->id, []))
|
||||
->reject->hasConnections()
|
||||
->each(function (Channel $channel, string $channelName) use ($connection) {
|
||||
unset($this->channels[$connection->app->id][$channelName]);
|
||||
});
|
||||
|
||||
if (count(array_get($this->channels, $connection->app->id, [])) === 0) {
|
||||
if (count(Arr::get($this->channels, $connection->app->id, [])) === 0) {
|
||||
unset($this->channels[$connection->app->id]);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
namespace BeyondCode\LaravelWebSockets\WebSockets\Messages;
|
||||
|
||||
use stdClass;
|
||||
use Illuminate\Support\Str;
|
||||
use Ratchet\ConnectionInterface;
|
||||
use BeyondCode\LaravelWebSockets\WebSockets\Channels\ChannelManager;
|
||||
|
||||
|
|
@ -28,7 +29,7 @@ class PusherChannelProtocolMessage implements PusherMessage
|
|||
|
||||
public function respond()
|
||||
{
|
||||
$eventName = camel_case(str_after($this->payload->event, ':'));
|
||||
$eventName = Str::camel(Str::after($this->payload->event, ':'));
|
||||
|
||||
if (method_exists($this, $eventName)) {
|
||||
call_user_func([$this, $eventName], $this->connection, $this->payload->data ?? new stdClass());
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
namespace BeyondCode\LaravelWebSockets\WebSockets\Messages;
|
||||
|
||||
use stdClass;
|
||||
use Illuminate\Support\Str;
|
||||
use Ratchet\ConnectionInterface;
|
||||
use BeyondCode\LaravelWebSockets\Dashboard\DashboardLogger;
|
||||
use BeyondCode\LaravelWebSockets\WebSockets\Channels\ChannelManager;
|
||||
|
|
@ -29,7 +30,7 @@ class PusherClientMessage implements PusherMessage
|
|||
|
||||
public function respond()
|
||||
{
|
||||
if (! starts_with($this->payload->event, 'client-')) {
|
||||
if (! Str::startsWith($this->payload->event, 'client-')) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace BeyondCode\LaravelWebSockets\WebSockets\Messages;
|
||||
|
||||
use Illuminate\Support\Str;
|
||||
use Ratchet\ConnectionInterface;
|
||||
use Ratchet\RFC6455\Messaging\MessageInterface;
|
||||
use BeyondCode\LaravelWebSockets\WebSockets\Channels\ChannelManager;
|
||||
|
|
@ -15,7 +16,7 @@ class PusherMessageFactory
|
|||
{
|
||||
$payload = json_decode($message->getPayload());
|
||||
|
||||
return starts_with($payload->event, 'pusher:')
|
||||
return Str::startsWith($payload->event, 'pusher:')
|
||||
? new PusherChannelProtocolMessage($payload, $connection, $channelManager)
|
||||
: new PusherClientMessage($payload, $connection, $channelManager);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ class ConfigAppProviderTest extends TestCase
|
|||
/** @var \BeyondCode\LaravelWebSockets\Apps\ConfigAppProvider */
|
||||
protected $configAppProvider;
|
||||
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ use BeyondCode\LaravelWebSockets\Statistics\Models\WebSocketsStatisticsEntry;
|
|||
|
||||
class CleanStatisticsTest extends TestCase
|
||||
{
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ abstract class TestCase extends \Orchestra\Testbench\TestCase
|
|||
/** @var \BeyondCode\LaravelWebSockets\WebSockets\Channels\ChannelManager */
|
||||
protected $channelManager;
|
||||
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue