2
2
3
3
namespace BeyondCode \LaravelWebSockets \Console ;
4
4
5
+ use React \Socket \Connector ;
6
+ use Clue \React \Buzz \Browser ;
7
+ use Illuminate \Console \Command ;
8
+ use React \EventLoop \Factory as LoopFactory ;
9
+ use BeyondCode \LaravelWebSockets \Statistics \DnsResolver ;
5
10
use BeyondCode \LaravelWebSockets \Facades \StatisticsLogger ;
6
11
use BeyondCode \LaravelWebSockets \Facades \WebSocketsRouter ;
7
- use BeyondCode \LaravelWebSockets \Server \Logger \ConnectionLogger ;
8
12
use BeyondCode \LaravelWebSockets \Server \Logger \HttpLogger ;
13
+ use BeyondCode \LaravelWebSockets \Server \WebSocketServerFactory ;
14
+ use BeyondCode \LaravelWebSockets \Server \Logger \ConnectionLogger ;
9
15
use BeyondCode \LaravelWebSockets \Server \Logger \WebsocketsLogger ;
10
- use BeyondCode \LaravelWebSockets \Statistics \ DnsResolver ;
16
+ use BeyondCode \LaravelWebSockets \WebSockets \ Channels \ ChannelManager ;
11
17
use BeyondCode \LaravelWebSockets \Statistics \Logger \HttpStatisticsLogger ;
12
18
use BeyondCode \LaravelWebSockets \Statistics \Logger \StatisticsLogger as StatisticsLoggerInterface ;
13
19
14
- use BeyondCode \LaravelWebSockets \WebSockets \Channels \ChannelManager ;
15
- use Clue \React \Buzz \Browser ;
16
- use Illuminate \Console \Command ;
17
- use BeyondCode \LaravelWebSockets \Server \WebSocketServerFactory ;
18
-
19
- use React \EventLoop \Factory as LoopFactory ;
20
- use React \Socket \Connector ;
21
-
22
20
class StartWebSocketServer extends Command
23
21
{
24
22
protected $ signature = 'websockets:serve {--host=0.0.0.0} {--port=6001} ' ;
@@ -49,16 +47,16 @@ public function handle()
49
47
protected function configureStatisticsLogger ()
50
48
{
51
49
$ connector = new Connector ($ this ->loop , [
52
- 'dns ' => new DnsResolver ()
50
+ 'dns ' => new DnsResolver (),
53
51
]);
54
52
55
53
$ browser = new Browser ($ this ->loop , $ connector );
56
54
57
- app ()->singleton (StatisticsLoggerInterface::class, function () use ($ browser ) {
55
+ app ()->singleton (StatisticsLoggerInterface::class, function () use ($ browser ) {
58
56
return new HttpStatisticsLogger (app (ChannelManager::class), $ browser );
59
57
});
60
58
61
- $ this ->loop ->addPeriodicTimer (config ('websockets.statistics.interval_in_seconds ' ), function () {
59
+ $ this ->loop ->addPeriodicTimer (config ('websockets.statistics.interval_in_seconds ' ), function () {
62
60
StatisticsLogger::save ();
63
61
});
64
62
@@ -67,7 +65,7 @@ protected function configureStatisticsLogger()
67
65
68
66
protected function configureHttpLogger ()
69
67
{
70
- app ()->singleton (HttpLogger::class, function () {
68
+ app ()->singleton (HttpLogger::class, function () {
71
69
return (new HttpLogger ($ this ->output ))
72
70
->enable (config ('app.debug ' ))
73
71
->verbose ($ this ->output ->isVerbose ());
@@ -78,7 +76,7 @@ protected function configureHttpLogger()
78
76
79
77
protected function configureMessageLogger ()
80
78
{
81
- app ()->singleton (WebsocketsLogger::class, function () {
79
+ app ()->singleton (WebsocketsLogger::class, function () {
82
80
return (new WebsocketsLogger ($ this ->output ))
83
81
->enable (config ('app.debug ' ))
84
82
->verbose ($ this ->output ->isVerbose ());
@@ -89,7 +87,7 @@ protected function configureMessageLogger()
89
87
90
88
protected function configureConnectionLogger ()
91
89
{
92
- app ()->bind (ConnectionLogger::class, function () {
90
+ app ()->bind (ConnectionLogger::class, function () {
93
91
return (new ConnectionLogger ($ this ->output ))
94
92
->enable (config ('app.debug ' ))
95
93
->verbose ($ this ->output ->isVerbose ());
@@ -111,7 +109,7 @@ protected function startWebSocketServer()
111
109
112
110
$ routes = WebSocketsRouter::getRoutes ();
113
111
114
- /** 🛰 Start the server 🛰 */
112
+ /* 🛰 Start the server 🛰 */
115
113
(new WebSocketServerFactory ())
116
114
->setLoop ($ this ->loop )
117
115
->useRoutes ($ routes )
0 commit comments