This repository was archived by the owner on Feb 7, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +14
-15
lines changed Expand file tree Collapse file tree 2 files changed +14
-15
lines changed Original file line number Diff line number Diff line change 7
7
use BeyondCode \LaravelWebSockets \WebSockets \Channels \ChannelManager ;
8
8
use Clue \React \Buzz \Browser ;
9
9
use GuzzleHttp \Client ;
10
+ use function GuzzleHttp \Psr7 \stream_for ;
10
11
use Ratchet \ConnectionInterface ;
11
12
12
13
class HttpStatisticsLogger implements StatisticsLogger
@@ -67,24 +68,17 @@ public function save()
67
68
echo 'in actual save method ' ;
68
69
69
70
foreach ($ this ->statistics as $ appId => $ statistic ) {
70
- echo " stats of $ {appId} " . $ statistic -> isEnabled () ? ' enabled ' : ' DISABLED! ' ;
71
+
71
72
if (!$ statistic ->isEnabled ()) {
72
73
continue ;
73
74
}
74
75
75
- echo 'posted ' ;
76
76
$ this ->browser
77
77
->post (
78
78
action ([WebsocketStatisticsEntriesController::class, 'store ' ]),
79
- [],
80
- $ statistic ->toArray ()
81
- )
82
- ->then (function () {
83
- echo 'fulfilled ' ;
84
- }, function ($ e ) {
85
- echo 'fulfilled ' ;
86
- dd ($ );
87
- });
79
+ ['Content-Type ' => 'application/json ' ],
80
+ stream_for (json_encode ($ statistic ->toArray ()))
81
+ );
88
82
89
83
// Reset connection and message count
90
84
$ currentConnectionCount = collect ($ this ->channelManager ->getChannels ($ appId ))
Original file line number Diff line number Diff line change 14
14
use BeyondCode \LaravelWebSockets \Apps \AppProvider ;
15
15
use Illuminate \Support \ServiceProvider ;
16
16
use BeyondCode \LaravelWebSockets \WebSockets \Channels \ChannelManager ;
17
+ use Illuminate \Support \Str ;
17
18
18
19
class WebSocketsServiceProvider extends ServiceProvider
19
20
{
@@ -31,6 +32,8 @@ public function boot()
31
32
32
33
$ this ->registerRouteMacro ();
33
34
35
+ $ this ->registerStatisticRoute ();
36
+
34
37
$ this ->registerDashboardGate ();
35
38
36
39
$ this ->loadViewsFrom (__DIR__ .'/../resources/views/ ' , 'websockets ' );
@@ -65,11 +68,13 @@ protected function registerRouteMacro()
65
68
Route::post ('auth ' , AuthenticateDashboard::class);
66
69
Route::post ('event ' , SendMessage::class);
67
70
});
71
+ });
72
+ }
68
73
69
- //TODO: add middleware
70
- Route:: prefix ( $ prefix )-> namespace ( '\\' )-> group ( function () {
71
- Route::post ( ' statistics ' , [WebsocketStatisticsEntriesController::class, ' store ' ]);
72
- } );
74
+ protected function registerStatisticRoute ()
75
+ {
76
+ Route::prefix ( ' /laravel-websockets ' )-> namespace ( '\\' )-> group ( function () {
77
+ Route:: post ( ' statistics ' , [WebsocketStatisticsEntriesController::class, ' store ' ] );
73
78
});
74
79
}
75
80
You can’t perform that action at this time.
0 commit comments