Skip to content
This repository has been archived by the owner on Feb 7, 2024. It is now read-only.

Commit

Permalink
Octane fixes (#734)
Browse files Browse the repository at this point in the history
  • Loading branch information
rennokki authored Apr 6, 2021
1 parent 583022a commit 0380f5e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 13 deletions.
17 changes: 9 additions & 8 deletions src/Console/StartWebSocketServer.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 64,9 @@ protected function configureStatisticsLogger()

$browser = new Browser($this->loop, $connector);

app()->singleton(StatisticsLoggerInterface::class, function () use ($browser) {
$class = config('websockets.statistics.logger', \BeyondCode\LaravelWebSockets\Statistics\Logger\HttpStatisticsLogger::class);
app()->singleton(StatisticsLoggerInterface::class, function ($app) use ($browser) {
$config = $app['config']['websockets'];
$class = $config['statistics']['logger'] ?? \BeyondCode\LaravelWebSockets\Statistics\Logger\HttpStatisticsLogger::class;

return new $class(app(ChannelManager::class), $browser);
});
Expand All @@ -79,9 80,9 @@ protected function configureStatisticsLogger()

protected function configureHttpLogger()
{
app()->singleton(HttpLogger::class, function () {
app()->singleton(HttpLogger::class, function ($app) {
return (new HttpLogger($this->output))
->enable($this->option('debug') ?: config('app.debug'))
->enable($this->option('debug') ?: ($app['config']['app']['debug'] ?? false))
->verbose($this->output->isVerbose());
});

Expand All @@ -90,9 91,9 @@ protected function configureHttpLogger()

protected function configureMessageLogger()
{
app()->singleton(WebsocketsLogger::class, function () {
app()->singleton(WebsocketsLogger::class, function ($app) {
return (new WebsocketsLogger($this->output))
->enable($this->option('debug') ?: config('app.debug'))
->enable($this->option('debug') ?: ($app['config']['app']['debug'] ?? false))
->verbose($this->output->isVerbose());
});

Expand All @@ -101,9 102,9 @@ protected function configureMessageLogger()

protected function configureConnectionLogger()
{
app()->bind(ConnectionLogger::class, function () {
app()->bind(ConnectionLogger::class, function ($app) {
return (new ConnectionLogger($this->output))
->enable(config('app.debug'))
->enable($app['config']['app']['debug'] ?? false)
->verbose($this->output->isVerbose());
});

Expand Down
14 changes: 9 additions & 5 deletions src/WebSocketsServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 50,17 @@ public function register()
return new Router();
});

$this->app->singleton(ChannelManager::class, function () {
return config('websockets.channel_manager') !== null && class_exists(config('websockets.channel_manager'))
? app(config('websockets.channel_manager')) : new ArrayChannelManager();
$this->app->singleton(ChannelManager::class, function ($app) {
$config = $app['config']['websockets'];

return ($config['channel_manager'] ?? null) !== null && class_exists($config['channel_manager'])
? app($config['channel_manager']) : new ArrayChannelManager();
});

$this->app->singleton(AppProvider::class, function () {
return app(config('websockets.app_provider'));
$this->app->singleton(AppProvider::class, function ($app) {
$config = $app['config']['websockets'];

return app($config['app_provider']);
});
}

Expand Down

0 comments on commit 0380f5e

Please sign in to comment.