diff --git a/src/Console/StartWebSocketServer.php b/src/Console/StartWebSocketServer.php index 215bbfd..7965975 100644 --- a/src/Console/StartWebSocketServer.php +++ b/src/Console/StartWebSocketServer.php @@ -42,6 +42,25 @@ class StartWebSocketServer extends Command ->startWebSocketServer(); } + protected function configureStatisticsLogger() + { + $handler = new HttpClientAdapter($this->loop); + + $client = new Client([ + 'handler' => HandlerStack::create($handler), + ]); + + app()->singleton('websockets.statisticslogger', function() use ($client) { + return new StatisticsLogger(app(ChannelManager::class, $client)); + }); + + $this->loop->addPeriodicTimer(60, function() { + StatisticsLogger::save($this->loop); + }); + + return $this; + } + protected function configureHttpLogger() { app()->singleton(HttpLogger::class, function() { @@ -75,25 +94,6 @@ class StartWebSocketServer extends Command return $this; } - protected function configureStatisticsLogger() - { - $handler = new HttpClientAdapter($this->loop); - - $client = new Client([ - 'handler' => HandlerStack::create($handler), - ]); - - app()->singleton('websockets.statisticslogger', function() use ($client) { - return new StatisticsLogger(app(ChannelManager::class, $client)); - }); - - $this->loop->addPeriodicTimer(60, function() { - StatisticsLogger::save($this->loop); - }); - - return $this; - } - protected function registerEchoRoutes() { WebSocketsRouter::echo();