This commit is contained in:
Marcel Pociot 2018-12-03 13:27:45 +01:00
parent 333da893dd
commit 18bea0529d
4 changed files with 23 additions and 2 deletions

View File

@ -0,0 +1,14 @@
<?php
namespace BeyondCode\LaravelWebSockets\Facades;
use Illuminate\Support\Facades\Facade;
/** @see \BeyondCode\LaravelWebSockets\Statistics\Logging\Logger */
class StatisticsLogger extends Facade
{
protected static function getFacadeAccessor()
{
return 'websockets.statisticslogger';
}
}

View File

@ -49,7 +49,7 @@ class Logger
protected function initializeStatistics($id)
{
if (!isset($this->statistics[$connection->app->id])) {
if (!isset($this->statistics[$id])) {
$this->statistics[$id] = new Statistic($id);
}
}

View File

@ -3,7 +3,7 @@
namespace BeyondCode\LaravelWebSockets\WebSockets;
use BeyondCode\LaravelWebSockets\Dashboard\DashboardLogger;
use BeyondCode\LaravelWebSockets\Events\ConnectionEstablished;
use BeyondCode\LaravelWebSockets\Facades\StatisticsLogger;
use BeyondCode\LaravelWebSockets\WebSockets\Exceptions\WebSocketException;
use BeyondCode\LaravelWebSockets\WebSockets\Messages\PusherMessageFactory;
use BeyondCode\LaravelWebSockets\QueryParameters;
@ -90,6 +90,8 @@ class WebSocketHandler implements MessageComponentInterface
DashboardLogger::connection($connection);
StatisticsLogger::connection($connection);
return $this;
}
}

View File

@ -7,6 +7,7 @@ use BeyondCode\LaravelWebSockets\Dashboard\Http\Controllers\SendMessage;
use BeyondCode\LaravelWebSockets\Dashboard\Http\Controllers\ShowDashboard;
use BeyondCode\LaravelWebSockets\Dashboard\Http\Middleware\Authorize;
use BeyondCode\LaravelWebSockets\Server\Router;
use BeyondCode\LaravelWebSockets\Statistics\Logging\Logger;
use Illuminate\Support\Facades\Gate;
use Illuminate\Support\Facades\Route;
use BeyondCode\LaravelWebSockets\Apps\AppProvider;
@ -50,6 +51,10 @@ class WebSocketsServiceProvider extends ServiceProvider
return new ChannelManager();
});
$this->app->singleton('websockets.statisticslogger', function() {
return new Logger(app(ChannelManager::class));
});
$this->app->singleton(AppProvider::class, function() {
return app(config('websockets.app_provider'));
});